I am trying to display a message if the user that is logged in is the author of the post. I am doing something wrong below. I logged in with a different user, the IDs change but I stil get the message “You are the author of this post”. Any ideas?
<?php $getid = $posts->post_author; ?> <?php echo 'Hello: ' . $getid; ?> <?php global $current_user; get_currentuserinfo(); echo 'Hi: ' . $current_user->display_name . "\n"; echo 'your user ID is: ' . $current_user->ID . "\n"; ?> <?php if ($getid == $current_user->ID); echo "You are the author of this post"; ?>
- The topic ‘Comparing the post author ID and logged in user ID’ is closed to new replies.