-
Author
-
November 5, 2013 at 19:18 #5993nicholaus1221Participant
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 🙂
NicholausNovember 6, 2013 at 18:07 #6080SQadminKeymasterHello,
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 CODEfunction 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 solutionNovember 7, 2013 at 19:07 #6198nicholaus1221ParticipantThank 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,
NicholausPS – I rated your theme 5 stars! 🙂
November 8, 2013 at 20:40 #6285SQadminKeymasterThanks for the rating. We appreciate it.
You can change the shortcode to include the name and to center it:COPY CODEfunction 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 -
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.