WordPress user roles
- 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 publication;
- Subscriber - can do nothing except editing his own profile;
User role to level:
- Administrator = level_10 - level_0
- Editor = level_7 - level_0
- Author = level_4 - level_0
- Contributor = level_1 - level_0
- Subscriber = level_0
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 ?>
User level to role:
- level_10 - level_8 = Administrator
- level_7 - level_5 = Editor
- level_4 - level_2 = Author
- level_1 = Contributor
- level_0 = Subscriber
Check user level:
<?php if( current_user_can( 'level_10' ) ){} if( current_user_can( 'level_9' ) ){} if( current_user_can( 'level_8' ) ){} if( current_user_can( 'level_7' ) ){} if( current_user_can( 'level_6' ) ){} if( current_user_can( 'level_5' ) ){} if( current_user_can( 'level_4' ) ){} if( current_user_can( 'level_3' ) ){} if( current_user_can( 'level_2' ) ){} if( current_user_can( 'level_1' ) ){} if( current_user_can( 'level_0' ) ){} ?>
Check if user is logged in:
<?php if( is_user_logged_in() ){} ?>
