Support » Fixing WordPress » user_can doesn't appear to be working?

  • Resolved KatieBen

    (@katieben)


    Hi – so I made several custom roles, with several custom capabilities. One of the roles does NOT have the capability “is_hidden”, while other custom roles do. However, when I run the following code, “hi” is returned for each user with a custom role, whether that role has the capability “is_hidden” or not:

    if(user_can($member->id, “is_hidden”)){
    echo “hi”;
    }

    I’ve checked the database directly to make sure the users have the correct roles. I’ve checked the wp_user_roles entry in the wp_options table, to make sure the capabilities are correct for each role. And I’ve printed out the user object, to be sure that the user’s object has the correct role. All check out just fine.

    What could I be doing wrong here? It doesn’t look like I’m caching anything, and besides, this has been a problem for a week. Any ideas?

    Thanks for any help or ideas you can give. (:

Viewing 2 replies - 1 through 2 (of 2 total)
  • To boot, I’m even removing the capability ‘is_hidden’ for the role that should not have this, in my functions file:

    $role = get_role(‘role_name’);
    $role->remove_cap(‘is_hidden’);

    Thoughts?

    Okay, figured it out!

    The deal is that a super admin has ANY capability, whether custom or not. So, I just made these people not-super-admins, and added back in the multisite capabilities I wanted.

    Done and done. (:

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘user_can doesn't appear to be working?’ is closed to new replies.