I’m trying to determine if a piece of content can be edited by a user. I would like all roles contributor and above to be authorized by a single check. Here’s my code:
if( empty( $post_id ) || !current_user_can('edit_post', $post_id) ) { return; }
Unfortunately, the only users that don’t get the return
are super admins. Any idea why?
And the correct capability name is
edit_posts
. So the correct way of usingcurrent_user_can
will be like following:UPDATE: I have removed the wrong statement, but as the asker mentioned he would like to allow all roles of contributors and above to be authorized for that particular check, I think just checking for
edit_posts
caps is enough. Sorry for the wrong statement.