Skip to content

Instantly share code, notes, and snippets.

@MarceloGlez
Created June 17, 2020 21:04
Show Gist options
  • Save MarceloGlez/d9c1215c35961b975040958340ae1886 to your computer and use it in GitHub Desktop.
Save MarceloGlez/d9c1215c35961b975040958340ae1886 to your computer and use it in GitHub Desktop.
Permisos por rol de usuario en Wordpress en function.php (Child theme) - Code Snippets
$user = wp_get_current_user();
if ( in_array( 'editor', (array) $user->roles ) ) {
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'index.php' ); //Escritorio
remove_menu_page( 'edit.php' ); //Entradas
remove_menu_page( 'edit-comments.php' ); //Comentarios
remove_menu_page( 'tools.php' ); //Herramientas
remove_menu_page( 'options-general.php' ); //Ajustes
remove_menu_page( 'edit.php?post_type=listing' ); //Item en url
remove_menu_page( 'upload.php' ); //Medios
remove_menu_page( 'themes.php' ); //Apariencia
remove_submenu_page( 'jetpack', 'jetpack' );
};
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.toplevel_page_jetpack,
.menu-icon-elementor_library,
#toplevel_page_elementor{
display:none;
}
</style>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment