Author capabilities: Deleting comments on their own published posts
You can add the capability by using add_cap. But as far as I know there is no way to do this only for their posts, so it would be for all posts.
You can add the capability by using add_cap. But as far as I know there is no way to do this only for their posts, so it would be for all posts.
This filter needs to return something. Try this function modify_contact_methods($profile_fields) { if(current_user_can(‘edit_users’)) { // Field addition and removal will be done here // Add new fields $profile_fields[‘company_name’] = ‘Company Name’; $profile_fields[‘company_id’] = ‘Company ID’; } return $profile_fields; } add_filter(‘user_contactmethods’, ‘modify_contact_methods’);
public function myplugin_role_has_cap($capabilities, $cap, $args) { if(!isset($capabilities[‘myplugin_access’])) { unset($capabilities[‘myplugin_delete_item’]); } return $capabilities; }add_filter(‘user_has_cap’, array($this, ‘myplugin_role_has_cap’), 0 , 3); Here is a better answer, that corresponds to my example. Let’s say the plugin, on activation, adds the 2 caps to a role, and that after that for some reasons, the access cap is revoked. Then, even … Read more
The edit_pages capability only allows a user to edit his own unpublished pages. It does neither allow to edit others pages (this would require the edit_others_pages capability) nor does it allow to publish or edit published pages (capabilities: publish_pages and edit_published_pages). I’d strongly recommend having a look on this wonderful table: https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table listing up all … Read more
I have the same requirement. I believe it’s a bug. I have today raised a WordPress TRAC reporting my findings. https://core.trac.wordpress.org/ticket/29714 Have a look and see if you’ve got the same problem. Workaround I have also developed a workaround that may allow you to make progress in the mean time. Create a filter function for … Read more
Users can only save their draft once before saving for revision
The problem was, that I changed the capabilities AFTER I already created the role. I noticed, that if I change the roles slug, the role became duplicated. So I searched, and found remove_role( ‘tabellenadmin’ ); Add that line somewhere before add_role(). You first have to remove the role, before you can change it.
Solved it for different edit pages for different roles. In my method resposible for rendering the field I have: if ( count( array_intersect( $allowed_editors, $user->roles ) ) < 1 ) $readonly = ‘readonly’; Which I later use to either set the input field as readonly or add/remove classes before rendering it. Still working for the … Read more
Check user capabilities or roles when registering the navigation menu. The data will remain accessible via wp_nav_menu, but users without the capabilities won’t see the location in Appearance -> Menu -> Manage locations. Note this will only prevent assigning menus to these locations. Any menu assigned to the location already will be manageable (if the … Read more
Using this code snippet makes it that an author will see now only his/her own posting and is only able to edit his/her own postings. Only Admins will now be able to edit all posting. You could try to replace ‘author’ with ‘extension_author’ and see if it works for you as wished. (Add snippet in … Read more