• I’m looking to implement a system in my plugin so that certain elements of the page are only seen by different levels of users. I’ve read the roles page and understand how to use that along with current_user_can, but one thing didn’t quite make sense to me: How do you designate non-registered users (i.e. anonymous web visitors)? In the list it appears that level 0 actually means normal registered users, not unregistered users, since it says level 0 can alter their profiles. So, using roles how can I have a test to allow anonymous users to see something?

    Basically I want the regular page to be visible to anyone, an area that might say something to registered users, and then maybe a message to editors and admins. If I use the current_user_can it seems to me that anonymous users just won’t be able to see anything.

    Hmmm, is it a case if the user is anonymous that current_user_can might be un-set? (as in not assigned any value at all? I wonder if this can be checked against in an isset statement to determine the anonymous status?)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter harknell

    (@harknell)

    Hmmm, I just tried something out and I think I have the opposite problem than I thought. It looks to me that user level 0 actually means both anonymous AND registered user level! I did a test to limit the view on level 0 and I was able to see the item as both registered and anonymous, so now the question is actually how do you allow registered people to see things that anonymous people can’t see?

    Thread Starter harknell

    (@harknell)

    Ok, found out the answer i think. You need to use “read” as the current_user_can field to determine registered users. the 0 level is both but “read” only gets recognised for registered users.

    Hmm, kind of funky, but I guess the number system is legacy so it’s not a big deal that it doesn’t work fully the way I expected it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Role level of non-registered viewer?’ is closed to new replies.