I need to be able to show some informations only to the author in his profile viewable in the front end, for istance I need to add a text under the avatar that only the author, if logged in, can see. This text will inform them that they can change the avatar anytime by adding it in their profile page... I could also add some more details... Is there a way to achieve this? Thanks!
-
Nothing at all! I've been searching on Google and here too with no luck. I guess everything is related to author_name, if he/she is logged than I show a text or anything else if another author is logged in but has a different name then the text is hided. I've no clue...– user27309Commented Mar 15, 2013 at 16:14
-
Not the name, but rather the ID. Have posted an answer that should hopefully help you get started.– David GardCommented Mar 15, 2013 at 16:22
Add a comment
|
2 Answers
You can check who the current user is and whether they have the same ID as the user that is being viewed.
global $current_user
wp_get_current_user();
if(the_author_meta('ID') === $current_user->ID) :
// Add your code here...
endif;
See these Codex pages for more information -
This one works for me...
<?php
global $current_user;<br>
get_currentuserinfo();
if (is_user_logged_in() && (current_user_can('edit_others_posts') ||
$current_user->ID == $post->post_author) ) {my text goes here');
}
?>