Last active
October 30, 2017 13:58
-
-
Save maugelves/25af8c84b7c5eac1dc3d2e37fdcfb12e to your computer and use it in GitHub Desktop.
Función para no permitir que un determinado rol acceda al escritorio de 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 | |
/** | |
* Función para que un determinado rol de usuario | |
* no pueda acceder al administrador de WordPress. | |
* | |
* @author Mauricio Gelves <mg@maugelves.com> | |
* | |
*/ | |
function mg_dashboard_redirect(){ | |
// Obtengo el usuario actual | |
$user = wp_get_current_user(); | |
// Pregunto por un rol específico | |
if( in_array( 'editor', $user->roles ) ): | |
// En caso que se encuentre en el array de roles lo redirecciono. | |
// En este caso lo estoy enviado al listado de páginas. | |
wp_redirect(admin_url('edit.php?post_type=page')); | |
exit; | |
endif; | |
} | |
add_action('load-index.php', 'mg_dashboard_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment