So I have the code below that should pull the user metadata of the currently logged-in user.
<?php
$current_user = wp_get_current_user();
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
?>
Now the issue is that I do not know where to put this code (I know, embarrassing). I can't put it on a page, because then the PHP code would show and wouldn't change into displaying anything. I thought of putting it in functions.php
, however there is no short code associated with this...
Second question I have is how can I implement this into a table? So let's say USERNAME is a row, and next to that, it should show the current user's username. I know how to code a table in Wordpress, I just am unaware of how to implement my code into it.
Any help would be appreciated!
Thanks.