Display Edit Link Only For Logged In and Author
-
Can someone tell me how to display a post edit link for post author when logged in?
I tried this:
<?php global $current_user; get_currentuserinfo(); if (is_user_logged_in() && $current_user->ID == $post->post_author) { echo ' <a href="<?php echo $edit_post; ?>">Edit</a>'; } ?>
Works perfectly displaying the link only for authors and logged in users but the link is dead. when you hover over the link it shows <?php echo $edit_post; ?> When you remove the conditional the Link works just fine.
I’ve also tried this function I found on the net:
function limit_edit_Link_wpse_85214($link) { global $post,$current_user; get_currentuserinfo(); if ($post->post_author == $current_user->ID) { return $link; } return false; } add_filter('get_edit_post_link','limit_edit_Link_wpse_85214');
Had no affect what so ever…
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display Edit Link Only For Logged In and Author’ is closed to new replies.