problem with capabilities and current_user_can()
-
I have added a function to functions.php to redirect users to posts-new.php after login and it works. However, I only want this to happen if the user logging in is a contributor. So I added the following:
/** Redirect after login */ function mysite_login_redirect(){ if ( current_user_can( 'manage_options' ) ) { return 'https://mysite.com/wp-admin/index.php';} else { return 'https://mysite.com/wp-admin/post-new.php';} } add_action( 'login_redirect', 'mysite_login_redirect');
In this state, both contributors and admins are redirected to post-new.php. To test it I modified the function so that users without the capability would be redirected:
if ( !current_user_can( 'ma ...
when I modified the function, both contributors and admins are redirected to index.php.So the function seems to work but this implies to me that it’s not seeing the ‘manage_options’ capability for admins. I’ve tried several admin-exclusive capabilities with the same results. Weird huh?
I should say that I am using the user role-editor-plugin but I disabled it and tested the functions with the same results.
I’m also using Active Directory Integration and Admin Menu Editor.
- The topic ‘problem with capabilities and current_user_can()’ is closed to new replies.