To achieve this recipe, we need the current_user_can() WordPress function. This function checks the given parameter, which is the level of the current user, and returns true if the level of the current user is superior or equals to the given parameter.
We don't want that an author or contributor can edit a published post. With current_user_can('level_10'), we're making sure that only administrator(s) can edit the post.
Then, we're using WordPress basic functions (bloginfo() and the_ID()) to build a direct link to the dashboard page where the post will be editable.
<?php
if (current_user_can('level_10')){ ?>
<a href="<?php bloginfo('wpurl');?>/wp-admin/edit.php?p=<?php the_ID(); ?>">Edit Post</a>
<?php } ?>
Leave a Comment