How to insert PHP code in the header(header.php) to get the corresponding value

Posted in: Newspaper
Post count: 2

This is the code to insert the header—-
<head>
<meta charset=”<?php bloginfo( ‘charset’ );?>” />
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<link rel=”pingback” href=”<?php bloginfo( ‘pingback_url’ ); ?>” />
<?php wp_head(); ?>
<?php
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$user_name = $current_user->display_name;
?>
</head>

This is the code in the Google Analytics and JavaScript Codes——————-
<!– Matomo Tag Manager –>
<script type=”text/javascript”>
var _mtm = _mtm || [];
_mtm.push({‘userid’: ‘<?php echo $user_id ?>’});
_mtm.push({‘username’: ‘<?php echo $user_name ?>’});
_mtm.push({‘mtm.startTime’: (new Date().getTime()), ‘event’: ‘mtm.Start’});
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=’text/javascript’; g.async=true; g.defer=true; g.src=’http://matomo.qlhclub.com/js/container_GS0xR0No_staging_30fc6a22e4691022894440ed.js&#8217;; s.parentNode.insertBefore(g,s);
</script>
<!– End Matomo Tag Manager –>

I need to get userid and username here

Post count: 2

Help~~~

Post count: 18283

Hello !

Header codes can be inserted in here: https://www.screencast.com/t/rD3n7AtOc5

At the moment the Support team is not 24/7 available. Please note that we answer the topics from Latest to Newest Monday – Friday from 08:00AM to 05:00PM GMT+2 So multiple replies to your topic will only make us to get harder to your topic.

Thank you !

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.