WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] user_can doesn't appear to be working? (3 posts)

  1. KatieBen
    Member
    Posted 3 years ago #

    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. (:

  2. KatieBen
    Member
    Posted 3 years ago #

    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?

  3. KatieBen
    Member
    Posted 3 years ago #

    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. (:

Topic Closed

This topic has been closed to new replies.

About this Topic