I've been using this code:
if (is_user_logged_in() && !current_user_can('subscriber')) { [...] }
... fine for a while now to show something only to users logged in above the level of subscribers (authors, admins, etc).
Recently I upgraded my install of WordPress to use the Multisite feature and ever since this bit of code has not worked.
Has anyone else had problems with current_user_can and Multisite?
current_user_can('subscriber')
Becasue on subsites, if they are not expressly listed as a user on that site, then this would return false.
I haven't started using any other subsites yet though so surely all the users from before the switch should be listed as users of the (main) site that this code is on?
Also, I am negating the current_user_can('subscriber') so even if it was returning false then that shouldn't matter...
current_user_can('read') is the equivalent of a subscriber. See http://codex.wordpress.org/Roles_and_Capabilities#Administrator for a complete list.
Thanks, changing the argument from the subscriber role to a different capability seems to have worked :)
Doh, yeah that was a bad argument to begin with. :)
Actually current_user_can says it will work on role check too
See
http://codex.wordpress.org/Function_Reference/current_user_can