Skip to content

Instantly share code, notes, and snippets.

@mingomax
Created June 25, 2013 20:44
Show Gist options
  • Save mingomax/5862196 to your computer and use it in GitHub Desktop.
Save mingomax/5862196 to your computer and use it in GitHub Desktop.
Como impedir que um usuário que não seja administrador altere o status de Post quando este já foi publicado #wordpress
<?php
function wp_restrict_editing( $allcaps, $cap, $args ) {
//Only for non Admin users
if(!current_user_can('administrator')) {
// Load the post data:
$post = get_post( $args[2] );
// Bail out if the post isn't published'
if( 'publish' != $post->post_status)
return $allcaps;
}
}
add_filter( 'user_has_cap', 'wp_restrict_editing', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment