Questions tagged [capabilities]

WordPress uses a concept of Roles, designed to give the site owner the ability to control what users can and cannot do within the site. Each role is allowed to perform a set of tasks called Capabilities.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

Adding plugin editing capability for Author

I am new to php environment. Any idea how we could enable plugin editing roles and capabilities for Author or another scenario could be adding as sub-admin with limited roles. Any help would be ...
0 votes
1 answer
65 views

User Capabilities are not available in WP REST permission callback?

I want to only permit the execution of specific admin tasks for users who are currently logged in to the wp admin panel (via is_user_logged_in) and who have a specific capability (via ...
  • 391
0 votes
1 answer
29 views

Prevent all users from editing posts except admins using hooks

So I'm attempting to block out all post edits for all users except admins, so I have the following setup: add_filter('post_row_actions', [self::class, 'remove_edit_permissions'], 10, 2); public ...
  • 15
0 votes
1 answer
24 views

Role capabilities issue

I need some help with capabilities for a CPT. I register a new CPT with a capability type 'agenda'. To do this I use the code below in the register array 'capability_type' => 'agenda', After ...
  • 27
0 votes
0 answers
14 views

How to fix the Post Preview Button (CPT & map_meta_cap)

I'm trying to create a custom post type that can be edited by users with a custom role (as well as administrators, editors and authors). Althought the idea for the users with this custom role is for ...
0 votes
0 answers
10 views

Restrict Custom Post Type per role in Dashboard

I would like to set up some restrictions on how some roles can access given posts to edit in Dashboard. I have a custom post type affiliates having 2 nested levels. Custom Role User Editor should be ...
  • 824
3 votes
0 answers
26 views

Locking Down Wordpress Application Password Permissions / Capabilities

I am working on a Wordpress installation where we recently decoupled the frontend into a NextJS application that is no longer hosted on the same domain as the admin. We are accessing data etc through ...
0 votes
0 answers
25 views

Why can my subscribers create new posts for review?

My subscribers seem to have permission to create posts. After reading the documentation on capabilities, this shouldn't be the case. Subscribers should only be able to manage their own profile. I have ...
  • 1,275
0 votes
1 answer
37 views

Restrict access to custom post type based on its taxonomy terms

I'm just beginning to understand the roles and capabilities in Wordpress and I'm not sure that I can do what I would like. I have a custom post type, "cats", that has specific taxonomies ...
0 votes
0 answers
10 views

Edit and delete permissions pages and posts

Does anybody know if it is possible to protects some pages and posts from editing / deleting unless if the role is admin? Not all posts and pages has to be protected against this! I can not read ...
0 votes
0 answers
14 views

Disabled delete_others_posts if post is from admin

I need some help with capabilities. I created a new role for my theme with the capability "delete_others_posts". This role can delete posts from other users and also from admins. Is there a ...
  • 27
0 votes
1 answer
17 views

How can I check if a visitor can read a post?

I know how to check capabilities for logged in users, with $can_read = current_user_can('read',$post->ID); But the above code returnes false when the user is not logged. So how can I check if the ...
  • 462
1 vote
1 answer
25 views

Add, edit specific CPT with custom role

Who can help me with roles and capabilities? I am stuck on this and I need some help. I want a role that only can add, remove edit etc. a specific CPT. What I have so far add_action('init', function(){...
  • 13
1 vote
1 answer
114 views

Remove Capabilities from WP admin for specific user role

I am trying to remove some menu-links capabilities from the wp-admin for a user role called wsm. I have tried many ways and when i just add the code below it will remove those links from the menu for ...
0 votes
0 answers
18 views

How to query users to count all with a custom capability and limit it to a set of roles?

On a site with 12 custom user roles I need to count users with the 'supervisor' custom capability but limited to four specific roles. The following code counts all users with the 'supervisor' ...
  • 327
0 votes
0 answers
34 views

Restrict access only of custom post type with standard capabilities to edit_post

I'd like some of our registered users to add MEC calendar events. Our admins would then review and publish them. MEC does not use custom capabilities, but standard ones. I'm already using Restrict ...
  • 121
0 votes
0 answers
124 views

user_has_cap filter allows "edit_others_posts" but not is not allowing updating/publishing

This filter is letting manager users edit specific posts created by other users: add_filter( 'user_has_cap', 'allow_manager', 10, 4 ); function allow_manager( $allcaps, $caps, $args, $user ) { // ...
  • 101
1 vote
0 answers
69 views

Custom post types as sub menu pages and role capabilities issue

I'm working on this: Create a menu entry in the admin panel name "Products" Have a dozen of custom post types, all as submenus items of my admin menu "Products" entry Allow a role ...
  • 111
0 votes
0 answers
26 views

REST API - Allow /users endpoint depending on a custom capability

I am in a situation where I have to list users for a frontend app dropdown via REST API. By default, WP will not allow listing of users without list_users cap. My plugin has its own custom capability ...
  • 7,625
0 votes
0 answers
29 views

remove "Edit" from select pages

I've had a good look around before asking this question so if it's already been cracked just point me in that direction! I've set up some custom core pages in order to work as "archive" ...
0 votes
0 answers
30 views

Why "Mine" is the default view when adding 'capability_type' in register_post_type

I'm tweaking default's wordpress permissions by adding my own via the capability_type and map_meta_cap in register_post_type(), but I noticed that as soon I add the capability_type argument, the ...
  • 11
0 votes
0 answers
33 views

Set edit capability based on ACF relationship

I have a CPT for Businesses, which have a relationship to another CPT, region. Users can edit their own businesses, but I also have regional managers that I would like to give the ability to edit ...
0 votes
1 answer
26 views

Which capabilities are available in Gravity Forms Salesforce plugin? [closed]

Which capabilities are there in Gravity Forms Salesforce plugin and what do they do?
0 votes
0 answers
17 views

cannot get global $menu value in form request

I have register a route for edit_audience register_rest_route( 'ilms_plugin', 'edit_audience', [ 'methods' => 'POST', 'callback' => 'edit_audience', 'permission_callback' => '...
0 votes
2 answers
290 views

Allow a user or role to view drafts and previews, but not other admin privileges?

How do I allow a specific user or a specific role to view drafts and previews, but not allow them to edit posts or have any other admin capabilities? I can add a custom capability to a role, but don't ...
  • 281
0 votes
1 answer
36 views

Taxonomy terms can still be added when only assign_terms capability has been granted

I'm setting the capabilities for a taxonomy with the below: $assoc_tax->capabilities['manage_terms'] = "zzz"; $assoc_tax->capabilities['edit_terms'] = "zzz"; $assoc_tax->...
  • 2,380
0 votes
1 answer
78 views

Adding all custom capabilities to admin

When adding a custom post type using the "capability_type" argument, custom capabilities are automatically generated for the post type. https://developer.wordpress.org/reference/functions/...
0 votes
0 answers
539 views

Undefined array key 0 wp-includes/capabilities.php on line 76

as in the title. I tried to find solution, but people got quite another issue... Line 76: $post = get_post( $args[0] ); if ( ! $post ) { $caps[] = 'do_not_allow'; break;...
0 votes
2 answers
208 views

WordPress: Custom User Role cannot access Custom Post Type | "Sorry, you are not allowed to access this page"

The Objective: Create a custom post type and only give administrator and a custom role permission to view / control it. The Problem: For administrators, it works perfectly fine but for the custom role ...
1 vote
0 answers
19 views

Add menu items/actions for multisite users who are registered on the network but do not have a role or capability in any sites

We've built a custom application (Pressbooks) that sits on top of WordPress multisite and transforms the multisite into a CMS for book publishing. A frequent flow for super admins is to invite a new ...
0 votes
1 answer
132 views

Give admin_menu permission to specific users

I created a admin menu for my Wordpress website. The capabillity / rules are set to manage_options. Now I want give permission to another user that is only an editor. Does anybody know how I can do ...
  • 27
0 votes
1 answer
462 views

Select other roles as custom post authors

I created a custom post type ("Organization"), and I've also created a custom user role ("Representative"). Also, I've ensured that the Representative role has read/edit/create/...
  • 125
1 vote
1 answer
346 views

Add condition of user capability in WP_query

I am struggling a bit with my WP_query which includes a meta_query to limit posts based on ACF User field, but show all posts if user can 'edit_posts'. From my code below, the first two arrays work ...
  • 21
0 votes
1 answer
57 views

How to keep the capability of users and disable Gutenberg editor in WordPress?

I disabled Gutenberg web builder/ editor using the following code: add_filter( 'use_block_editor_for_post', '__return_false' ); Somehow this impacted contributor's capability to submit post for ...
  • 39
0 votes
2 answers
50 views

How to add custom JavaScript in functions?

I want to write some JavaScript and want to assign that to a custom capability, I explored a lot but unfortunately none of them worked, any help will be appriciated. My codes are as below: add_action('...
  • 39
0 votes
1 answer
25 views

How to write conditions based on user capabilities not on user role?

How to write conditions on capabilities not on user role?
  • 39
0 votes
0 answers
86 views

See which user role / capability is needed to use a plugin

I have installed a plugin (https://de.wordpress.org/plugins/food-and-drink-menu/) for which I want to assign permissions to a normal "editor" user. I found the plugin "User Role Editor&...
  • 152
1 vote
1 answer
61 views

Logout users upon login, based on caps/role?

To reduce spam registrations, users are assigned the pending role until they're vetted (at which point they're assigned the subscriber role). The pending role has no capabilities. When pending users ...
0 votes
1 answer
361 views

How to get all capabilities

how to get all capabilities regardless of user roles? so far I am only seeing tutorial of how to get capabilities per user. I want to list all available capabilities in one page.
  • 17
0 votes
0 answers
37 views

CPT requires manage_options and edit_posts for some reason

I made a CPT called sponsor. I set map_meta_cap to true and capability_type to sponsor. I created a custom role that has edit_sponsors, as well as all the other stems (delete, publish, etc., each with ...
0 votes
0 answers
23 views

User role and capablities only for 1 plugin

What if i want a user called Marketing only to see the Slimstat plugin? The rest of the admin menu should be invisible for him. (for a external marketing agency that should see our stats but only our ...
1 vote
0 answers
52 views

My subscriber has the "edit comment" capability but can't edit comment

When i use the wp_get_current_user function to display all informations about my user (subscriber), it shows that i can edit comment : I tried to display an edit comment button next to each comment ...
0 votes
0 answers
26 views

How can restrict certain users from delete a category but can view only in wordpress?

I would like to remove the capability of 'delete_term' for certain users. If can find the code which shows the 'delete' from 'wp-admin/includes/class-wp-terms-list-table.php' line number so where ...
  • 1
0 votes
1 answer
233 views

current_user_can() causing critical error

I am writing a function to add a link to the Media Library in the admin menu on front end: function add_media_link_to_admin_menu( $wp_admin_bar ) { // add Media Library to admin menu $...
0 votes
0 answers
62 views

How to give plugin access to specific role(s)

How do I restrict plugin access to a specific user role? I wrote/installed a simple plugin that's listed in the left navbar in wp-admin. However, I'd like to only have it show for specific roles. I ...
2 votes
0 answers
118 views

Custom post type capabilities require "create_posts" to access the edit posts list page

I have a custom post type and a custom user role that I want to be able to do everything but delete and create this post type. However, this user role can't view the dashboard's list of posts for ...
0 votes
0 answers
23 views

Allow contributor user role to perform copy operation PHP

I have posted the issue on Stack Overflow but didn't get any solution. So now I am posting here. I want to allow contributor user role can copy file from one location to another location. I am using ...
  • 31
0 votes
1 answer
253 views

Allow comments only for custom post type

I want to allow comments only for custom post types but not for normal posts or pages. What would be the best way to do that? I can think of one way that is a bit ugly. One would be to remove the ...
0 votes
1 answer
95 views

How to make WordPress 'editor' role to list/view/add/edit users only with the role 'author'?

I have added some extra capabilities to the existing 'editor' role in wordpress with: function add_uedit_caps() { $role = get_role('editor'); $role->add_cap('create_users'); $role->...
  • 213
0 votes
0 answers
98 views

current_user_can( 'edit_user' ) does not work

I don´t clearly understand why this code does not work : //Front-end profile page global $current_user; if ( current_user_can( 'edit_user') ) { ... } $current_user output : ["allcaps"]=> ...
  • 770

1
2 3 4 5
11