Hi Melanie. Not sure if this is it but it appears that you’re missing a closing bracket } at the end of your first “if” statement.
thank you! bdbrown
Melanie 🙂
still not working – both redirected to homepage
// 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( 'http://photohunters.org/add-star' );
} // if
if ( 'administrator' === $role_name ) {
wp_redirect( 'http://photohunters.org/wp-admin' );
}
} // wp_redirect_users_by_role
add_action( 'admin_init', 'wp_redirect_users_by_role' );
Hi Am trying various scripts but end up on home page
here is latest
// redirect editor
function editor_redirect( $redirect, $user ){
$role = $user->roles[0];
$addstar = get_permalink( get_page_id( '/add-star/' ) );
if( $role == 'editor' )
$redirect = $addstar;}
still no joy
does anyone have a ny ideas?
Your next to last snippet works in part. The redirects all need to be permalinks to WP content. Redirects to actual PHP pages or folders will not work. If need be, a custom page template could serve as a shell for a particular backend page, just so you have a permalink to redirect to.
The thing is though, once the redirects work correctly, the user is then locked into that page for any backend request. That may be fine for low capability users, but editors and administrators would not be happy with such an arrangement.
Hi bcworkz, that is my point, the “editor” is only able to go to this page and has to log out once his job is finished, only he/she can enter this page as if someone without “editor” role enters they are sent away. the permalink is correct the page is called “add-star”, but it doesnt work, they get directed to the homepage???
thanks
Melanie
If redirects to a permalink are not working for you, I have to think there is some plugin or theme conflict at work in your installation, because they do work with mine, which is nearly “out of the box” condition. If you were to reduce your installation to such a state (deactivate all plugins and switch to a twenty something theme), you should find at least the editor redirect will work.
You can then restore your theme and plugins, one by one, checking the redirect each time. Once it fails again, the last added component is the trouble maker. You could then perhaps take up the issue with the component’s author.
thank you bcworkz, will have a go, Melanie