• Resolved gpspake

    (@gpspake)


    So here’s the issue we’re having, and we aren’t quite sure if it’s the plugin that’s causing it…

    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 'http://mysite.com/wp-admin/index.php';}
            else {
               return 'http://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?

    The function doesn’t work correctly and the problem seems to be that neither roles nor capabilities are being recognized by the function correctly. If I set current_user_has() to an administrator specific role, or just ‘administrator’, it should use the ‘if’ url if I log in as an admin, and the ‘else’ url if I log in as a contributor. Either way, whether I set the function to ‘current_user_can’ or ‘!current_user_can’, the administrator login and the contributor login behave the same as if the capabilities are not any different.

    Is this because the plugin is affecting capabilities?

    http://wordpress.org/extend/plugins/active-directory-integration/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘It's working great, but is it causing problems with roles and capabilities?’ is closed to new replies.