I'm trying to create shortcodes that will display both avatar and logged in user first name in a text widget. I have managed to create something that displays the avatar, but not the username.
My code is as follows:
<?php
// show user avatar if logged in
function colaborator_avatar($atts)
{
if (is_user_logged_in() && !is_feed()) {
return get_avatar(get_the_author_meta( 'user_email' ));
}
}
add_shortcode('colaborator_avatar', 'colaborator_avatar');
// show user avatar if logged in
/**/
function colaborator_nome($atts)
{
if (is_user_logged_in() && !is_feed()) {
return get_user_meta( $new_user->ID, 'first_name', true );
}
}
add_shortcode('colaborator_nome', 'colaborator_nome');
?>
Have in mind that this is not for an specific ID, this to show on screen which user is logged in.
By the way, is it possible to define the avatar's size?
EDITED: Corrected a typo error in the code.