Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [user-roles]

Names for a set of user capabilities.

Filter by
Sorted by
Tagged with
103 votes
7 answers
278k views

How to check if a user is in a specific role?

I have a pretty specific requirement to show different text in a field label on the user profile page based on the current user's role. I can't seem to figure out how to check whether the current use ...
jessegavin's user avatar
  • 3,446
167 votes
6 answers
420k views

If the current user is an administrator or editor

How can I check to see if the current logged-in user is an administrator or an editor? I know how to do each individually: <?php if(current_user_can('editor')) { ?> <!-- Stuff here for ...
andy's user avatar
  • 2,359
14 votes
5 answers
16k views

How do I make a draft post accessible to everyone?

I have several unpublished posts in my Wordpress website and I am trying to make it accessible for normal users (who are not logged in) using the normal post slugs (site.com/post-here). I understand ...
Amal Murali's user avatar
8 votes
1 answer
5k views

Allow Editors to edit pending posts but not draft ones

I have a large number of users with Editor Capabilities that help to go through the post submissions. This is my current setup for this role: As you can see, they are allowed to edit_posts and ...
Christine Cooper's user avatar
  • 8,798
34 votes
5 answers
67k views

Allow member to have access to custom post type only. Permission to only edit their own posts

OK I'm looking for the best way to attack this. I'm very comfortable with PHP and making custom post types with custom meta fields in WordPress. Here is what I'm looking at doing: User registers ...
Scott's user avatar
  • 12.2k
6 votes
1 answer
11k views

How to assign specific users the capability to edit specific pages / posts / custom post types

I'm trying to implement what seemed like a relatively straight forward idea, basically I am building an access control plugin to control viewing and editing of a custom post type (in this case '...
Rick Curran's user avatar
  • 1,076
49 votes
6 answers
57k views

Getting a List of Currently Available Roles on a WordPress Site?

When writing WordPress plugins there is often a need to set up options for which roles on the site have access to certain functionality or content. To do this a plugin dev needs to fetch the list of ...
jerclarke's user avatar
  • 3,043
25 votes
6 answers
54k views

Possible to hide Custom Post Type UI/Menu from specific User Roles?

What I'm looking to do is completely hide the UI for a custom post type from specific user roles...Ive previously found many resources on how to disable access to using those CPTs but nothing that ...
Mr.Brown's user avatar
  • 1,025
15 votes
4 answers
16k views

Remove Ability for Other Users to View Administrator in User List?

(Moderator's note: Original title was "Remove Admin from User Menu") I have created a client administrator role which is essentially an Editor with ability to add/remove users. The article "Editor ...
Carlos's user avatar
  • 153
11 votes
1 answer
9k views

Change author base slug for different roles

Is it possible to change the author base slug according to his role? For example, authors get example.com/ninja/%username% and subscribers get example.com/trainee/%username%? I am thinking of ...
Maxim Zubarev's user avatar
9 votes
3 answers
6k views

How to prevent a post from being deleted?

For auditing issue, I only want a post can be trashed, but not deleted - for all users. So I have a plugin like add_action('before_delete_post', function($id) { wp_die(0); }); But seems ...
Yoga's user avatar
  • 909
5 votes
1 answer
3k views

Help to condense/optimize some working code

WordPress by default shows ALL posts to users who are Authors. I wanted Authors to only be able to see their own posts so I came up with the following code which works well. Any suggestions to ...
Paul's user avatar
  • 958
55 votes
7 answers
85k views

allow editors to edit menus?

I would like to be able to grant my editors the power to change the menu, can this be done? The appearance tab doesn't appear to be an option at all, can I make it so?
Mild Fuzz's user avatar
  • 4,180
42 votes
4 answers
21k views

Editor can create any new user except administrator

I have set up a WordPress site for a client. The client has the Editor role, however I have installed the Members plugin and given the client the capability to add new users to the WP admin. This is ...
Vayu's user avatar
  • 519
24 votes
5 answers
29k views

How can I allow the Editor Role to change Theme Settings?

I've just setup a new Blog for a friend and thought it's better to not give him Administrator Access right away as a precaution. I created a new user as Editor therefore. But then I saw that this ...
hakre's user avatar
  • 12.9k
20 votes
2 answers
11k views

How to allow an user role to create a new user under a role which lower than his level only?

I have three extra roles in my site. Doctor Receptionist Guest those roles are added by following code: * adding Doctor role */ $doctor_role = add_role('Doctor', __('Doctor'), array('read'=>'...
Riffaz Starr's user avatar
18 votes
2 answers
46k views

How to add a Capability to a User Role?

I am managing a Wordpress network and would like to add the unfiltered_html user capability to the already predefined user role of Admin. In a standard installation of Wordpress the Admin account ...
Jonnybojangles's user avatar
17 votes
1 answer
31k views

Separate registration and login for different roles

I've set 2 new roles for my site using the "Members" plugin - "sellers" and "buyers". Each role should have its own registration page and login. A visitor can register as both a buyer and a seller ...
Ash's user avatar
  • 175
16 votes
8 answers
17k views

Select subscriber as author of post in admin panel?

I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login ...
fxfuture's user avatar
  • 1,337
12 votes
2 answers
6k views

add_role() run only once?

I was surprised to discover that add_role() modifies the database and fails if the role already exists. There are two implications here, one first more serious than the other: 1) if you're in ...
Tom Auger's user avatar
  • 7,046
10 votes
5 answers
14k views

WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins

I have multi-author website and I am not very comfortable for allowing all members to enter SEO details in the posts they are publishing. I would like this would be visible only to Administrator of ...
Audrius's user avatar
  • 111
10 votes
6 answers
41k views

How to prevent access to wp-admin for certain user roles?

I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two ...
Claire's user avatar
  • 342
7 votes
2 answers
7k views

Deactivate plugin for a specific user group

I would like to deactivate a plugin for a specific user. I'm using the following code inside a the wp-content/plugin-mu plugin file: add_filter( 'option_active_plugins', 'bo_disable_apm_plugin' ); ...
Simon's user avatar
  • 1,218
4 votes
2 answers
1k views

How can I display all Multisite blogs where this user is administrator?

Given the user ID, how can I display all the blogs where this user is administrator? I tried: <?php $user_id = 2; $user_blogs = get_blogs_of_user( $user_id ); echo '<ul>'; foreach ($...
Ken's user avatar
  • 369
4 votes
1 answer
12k views

Apply custom role capabilities to administrator (without plugin)

I have a custom role that allows access to only a sigle custom post type. This is all well and good, but now it is only showing up for this role, not for admin and super admin. I'm having a hard time ...
kristina childs's user avatar
3 votes
2 answers
3k views

Ordering users of a specific role by last name

I'm trying to display a list of authors by their last name. I can get the list to display but as yet I don't seem to be able to order the list by last name. Any help would be greatly appreciated. Josh ...
Josh's user avatar
  • 59
54 votes
9 answers
127k views

How to change a user's role?

I have custom roles in my setup and I want to be able to automatically change a user's role thru a function. Say user A has a SUBSCRIBER role, how do I change it to EDITOR? When adding a role we just: ...
Joann's user avatar
  • 1,485
28 votes
5 answers
23k views

How to create a clone role in wordpress

How to create new role with same capabilities of existing role. Eg: I would like to create a new role with same capabilities of administrator or editor and so on..
Aadi's user avatar
  • 507
18 votes
4 answers
70k views

How can I get a list of users by their role?

How can I get a list of all users that are in WordPress by their role or capabilities? For example: Display all subscribers list in WordPress. Display all authors list in WordPress. Display all ...
Raja Usman Mehmood's user avatar
16 votes
7 answers
17k views

Why are my roles not visible in a Multi-site/Network?

My network is showing roles in some sites and not in others. For some reason that I can't explain, when I add a new user, I have no roles to choose from in the drop down box of a sub-site in my ...
Geo's user avatar
  • 747
14 votes
4 answers
33k views

How do I programmatically set default role for new users?

I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend.
jayarjo's user avatar
  • 518
10 votes
3 answers
30k views

Send user activation email when programmatically creating user

I wondered if someone here might be able to help. Basically, I've created a custom registration form that when validated, inserts a user to the user table. function _new_user($data) { // ...
Joe Buckle's user avatar
7 votes
1 answer
4k views

Temporary capability for current_user_can()

Is it possible to intercept calls to current_user_can() ? Example: current_user_can('rate', $post_id) There's no "rate" capability registered, but could I somehow hook into that function and do my ...
onetrickpony's user avatar
  • 13.6k
7 votes
4 answers
17k views

Allowing users to edit only their page and nobody else's

We currently have about 50 pages, each of which I want a user (eg, bob, rob, smith) to be able to edit only 1 page. For example, bob & smith each have their own page. I do not want bob to be ...
zealeus's user avatar
  • 73
6 votes
5 answers
7k views

How can I hide a category from Contributors in the edit/add new post screen?

I have a situation where I need to hide a specific category and it's children from users who are logged in as Contributors. I don't want them to see this category and it's children in the categories ...
davemac's user avatar
  • 648
5 votes
1 answer
3k views

Disable posts, only allow to edit existing pages, not create new ones (create_posts)

I am trying to limit a user role to only be able to edit existing pages, but not create new ones or do anything else like anything with posts. I have read this: Is there an existing capability to ...
kraftner's user avatar
  • 5,608
4 votes
1 answer
3k views

How to target with css, admin elements according to user role level?

I am using plugins "Capability Manager Enhanced" and "Adminimize". Between these two I have been able to do much of what I want to do. There are still some elements I need to hide and have been able ...
Bob Nelson's user avatar
4 votes
3 answers
9k views

Only allow administrators and editors to access wp-admin

I am trying to restrict access to wp-admin so that only administrators and editors are allowed. At the moment I am using this function: function restrict_admin(){ //if not administrator, kill ...
user avatar
4 votes
2 answers
6k views

Add role that restricts user to post in specific category

I'm trying to create a role that restricts the ability to post to a specific category, hiding the other from the checkbox. I don't want to use plugins. I'm looking for a snippet to put in functions....
MultiformeIngegno's user avatar
4 votes
2 answers
7k views

How to limit user to publish post per day and per role?

I would like to know is there any way/Plugin to limit the user published post (in a given time span) by his role? Like this: Role A -> 1 post per day and 30 post total. Role B -> 10 post per ...
dev-jim's user avatar
  • 1,978
4 votes
3 answers
4k views

Set a maximum upload count for users on a specific user role

For users with the Contributor user role, I want to restrict the total amount of images that they are allowed to upload. I found this code posted on an answer here: add_filter( 'wp_handle_upload', '...
Christine Cooper's user avatar
  • 8,798
3 votes
2 answers
2k views

Allow user to Publish, but not Edit or Delete

I saw post Allow Content Author to Publish, But Not Edit or Delete but is not the same I need and I cannot ask there because of reputation ¬¬ I need an user that can publish any user's post but can't ...
xotihcan's user avatar
3 votes
2 answers
6k views

How to filter the role selector?

I know that roles in WordPress are not hierarchical, but I'm wondering if there is any type of capability to "assign users to roles". All I can see if being able to add users or not. The real kicker ...
Zach's user avatar
  • 1,923
3 votes
4 answers
22k views

Remove ability to access certain admin menus

I am trying to remove some of the admin features for a user with the role of contributor. What i mean by remove some of the admin features is disable them from seeing certain admin menu items, such as ...
RoseCoder's user avatar
  • 181
2 votes
2 answers
1k views

Remove Ability for Administrators to Delete Administrators

I've been studying roles and capabilities and have worked with and worked up a bunch of awesome code for creating unique capabilities and roles. I have created a "Master Editor" role to maintain users ...
Ben Racicot's user avatar
  • 1,416
2 votes
1 answer
4k views

How to allow registered users to change their user role through frontend?

From time to time i want to give my registered users the chance to upgrade their user role by themselves for free. I tried this by writing a little plugin, but sady i can't get the html form to show ...
JulesB's user avatar
  • 21
1 vote
1 answer
50 views

if role is logged in then do something

I need some pro eyes please. Over all, I'm adding one button/link to the MAIN NAV depending on the logged in role. I have this “working” code: if ( ! function_exists( 'add_extra_item_to_nav_menu' ) ){ ...
Mike - Bain - Loucas's user avatar
1 vote
0 answers
182 views

Editor and contributor roles not correct after adding function

** RESTATED ** I am creating a bridge. The work involves a default installation of WordPress and a plugin to bridge a forum and WordPress. The forum provides all the account information. The ...
LPH's user avatar
  • 808
1 vote
2 answers
5k views

Order users by custom user meta

I'm showing a list of users like so: <ul> <?php $directors = get_users('role=director'); foreach ($directors as $director) { $dir_id = $director->ID; ...
Niels's user avatar
  • 524
0 votes
1 answer
191 views

how to make author to write comment on only his own posts?

i want restrict my registered authors to write comment to other posts except his own posts. Is it possible? I have no idea how to do it. May be need conditional logic but how?
Ramin Mahmudov's user avatar