redirect user by role
-
Hi am trying to redirect specific users to a custom page, have tried to add different code snippets to my functions page, some dont work others send all users there – below is i presume the basic code which does not seem to work though it should?
′// Redirect editor
function wp_redirect_users_by_role() {$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];if ( ‘editor’ === $role_name ) {
wp_redirect( ‘https://photohunters.org/add-star’ );
if ( ‘administrator’ === $role_name ) {
wp_redirect( ‘https://photohunters.org/wp-admin’ );
} // if} // wp_redirect_users_by_role
add_action( ‘admin_init’, ‘wp_redirect_users_by_role’ ); ′thanks Melanie
- The topic ‘redirect user by role’ is closed to new replies.