WordPress user capabilities

WordPress user roles

  • Super Admin - admin of the whole Network, can manage each site and everything in the Network
  • Administrator - can do everything
  • Editor - can create, edit and delete main items: pages, posts, comments, media
  • Author - can view other people's articles; create, edit and publish his own articles
  • Contributor - can view other people's articles; create, edit and send his own articles for approval before publish
  • Subscriber - can do nothing except of editing his own profile

Check user role:

<?php
if( current_user_can( 'administrator' ) ) {} // only if administrator
if( current_user_can( 'editor' ) ) {} // only if editor
if( current_user_can( 'author' ) ) {} // only if author
if( current_user_can( 'contributor' ) ) {} // only if contributor
if( current_user_can( 'subscriber' ) ) {} // only if subscriber
?>

Check if user is logged in:

<?php
if( is_user_logged_in() ) {}
?>

2 thoughts on “WordPress user capabilities”

Leave a Comment