This topic has 3 replies, 2 voices, and was last updated 11 years by SQadmin.

  • Author
  • #5993
     nicholaus1221
    Participant

    Hi,

    Just wondering, is there a shortcode for displaying the user that’s logged in only? I’d like to display the user avatar circle like on the members page for a leaderboard page I have. If not, is there a code snippet that would add this to a specific page?

    Thank you for your help,
    I love the theme 🙂
    Nicholaus

    #6080
     SQadmin
    Keymaster

    Hello,
    We’re glad you love our theme and please rate it if you haven’t already.
    We created for you this shortcode to display logged in member avatar.
    Shortcode is [kleo_my_avatar]

    Add this code to sweetdate-child/functions.php

    COPY CODE
    
    function kleo_my_avatar() {
    	global $current_user;
    	get_currentuserinfo();
    	$output = '';
    	$output .= '<div class="friend-item" style="text-align:left;"><div class="avatar" style="margin:inherit;">';
    	$output .= get_avatar( $current_user->ID, 94 );
    	$output .= '</div></div>';
    	
    	return $output;
    }
    add_shortcode('kleo_my_avatar', 'kleo_my_avatar');
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6198
     nicholaus1221
    Participant

    Thank you! The avatar looks great, I can’t get it to center though and I also can’t figure out how to have the name of the user be displayed above or below the avatar.

    Can you help?

    Thank you,
    Nicholaus

    PS – I rated your theme 5 stars! 🙂

    #6285
     SQadmin
    Keymaster

    Thanks for the rating. We appreciate it.
    You can change the shortcode to include the name and to center it:

    COPY CODE
    
    function kleo_my_avatar() {
    	global $current_user;
    	get_currentuserinfo();
    	$output = '';
    	$output .= '<div class="friend-item" style="text-align:center;"><div class="avatar">';
    	$output .= get_avatar( $current_user->ID, 94 );
    	$output .= '</div>';
    	$output .= '<span class="member-name">'.$current_user->display_name .'</span></div>';
    	
    	return $output;
    }
    add_shortcode('kleo_my_avatar', 'kleo_my_avatar');
    

    Please adapt your code in you need extra things added

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?