Last active
May 4, 2018 14:36
-
-
Save danilosong/2b5b357d5c56e961e30fd425de0323c3 to your computer and use it in GitHub Desktop.
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
/** | |
* Altera o select de "Autor" da funçao wp_dropdown_users, | |
* pelo valor do usuario que está editando no momento, valido apenas se o | |
* usuário não for administrator. | |
* | |
* @since 04-05-2018 | |
* @author Danilo Song <danilosong@outlook.com> | |
* @version 1.0 | |
* | |
* @global int $user_ID | |
* @param WP_Post $post Current post object. | |
*/ | |
function wp_dropdown_users_custom($post) { | |
global $user_ID; | |
$user = wp_get_current_user(); | |
$role = join('', $user->roles); | |
if($role != "administrator"){ | |
$post = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">"; | |
//Filtra somente se o usuário nã for administrator | |
$post .= '<option value="'.$user_ID.'" selected="selected" >'.$user->display_name.' ('.$user->nickname.')</option>'; | |
$post .= "</select>"; | |
} | |
return $post; | |
} | |
add_filter('wp_dropdown_users', 'wp_dropdown_users_custom', 10, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment