Skip to content

Instantly share code, notes, and snippets.

@manchumahara
Created March 1, 2014 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manchumahara/9293231 to your computer and use it in GitHub Desktop.
Save manchumahara/9293231 to your computer and use it in GitHub Desktop.
Sometimes we need to play post edit link for admin, editor or author himself. To place the edit link on frontend it's need to take care a bit so that the edit link is not visible to any unauthorized user. So my choice is showing the edit link who has other post edit permission and the author himself.
global $post, $current_user;
get_currentuserinfo();
if(current_user_can( 'edit_others_posts', $post->ID ) || ($post->post_author == $current_user->ID)) {
//show edit link
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment