Created
June 25, 2013 20:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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