Support » Fixing WordPress » problem with capabilities and current_user_can()

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try using:

    if ( current_user_can( 'edit_posts' ) ) {

    instead of:

    if ( current_user_can( 'manage_options' ) ) {

    Thanks for the quick response.
    I get the same results when I use ‘edit_posts’

    Someone in another forum suggested using ‘administrator’ instead of ‘edit_posts’ but this didn’t work. If I understand correctly, current_user_can() only applies to capabilities and not user roles. Can anyone help me figure out why this won’t work when I’m using a capability that is exclusive to admins?

    Mike Schinkel

    (@mikeschinkel)

    Try this maybe?

    function mysite_login_redirect( $redirect_url, $POST_redirect_url, $user ) {
      if ( is_a( $user, 'WP_User' ) ) {
        if ( $user->has_cap( 'manage_options' ) ) {
          $redirect_url = admin_url();
        } else {
          $redirect_url = admin_url('post-new.php');
        }
      }
      return $redirect_url;
    }
    add_action( 'login_redirect', 'mysite_login_redirect', 10, 3 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘problem with capabilities and current_user_can()’ is closed to new replies.