#32617 closed defect (bug) (invalid)
After adding the 'edit_posts' capability to 'subscriber' and turning off, the added role still remains
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.2.2 |
| Component: | Role/Capability | Keywords: | |
| Focuses: | administration | Cc: |
Description
// Add capabilities to "subscriber" user role
add_action('admin_init', 'subscriber_role_upload_files');
function subscriber_role_upload_files() {
$role = get_role('subscriber');
$role->add_cap('upload_files');
//$role->add_cap('edit_posts');
}
After adding the 'edit_posts' capability to 'subscriber' user role and turning off, the added role still remains. This code presented in a child functions.php file.
Change History (5)
#2
@
11 years ago
But I need edit_posts for the media uploader to work properly with 'subscriber' users at frontend (with Theme My Login plugin). if I not give this role to subscribers, the "crunching" will hang at image upload.
#3
@
10 years ago
- Keywords close removed
- Resolution set to invalid
- Status changed from new to closed
Hello @DJviolin
Welcome to Trac
I'm sorry, but I not quite sure I understand your problem.
If you need to add capabilities to roles, I suggest a role manager or capability manager plugin. A theme should not make permanent changes to roles on every page load. Capabilities may be manipulated from functions.php using the map_meta_cap filter.
Since I can't see any indication of a core bug in your report and latest comment, I have to suggest you try our support forum https://wordpress.org/support/. The people there are most capable of helping you do what you want the right way.
If it should later become evident there is, or may be, a bug in core, please feel free to reopen this ticket.
#4
@
10 years ago
I found the solution here:
https://core.trac.wordpress.org/ticket/19834#comment:19
I modified to my needs:
function fix_media_permissions() {
global $wp_post_types;
$wp_post_types['attachment']->cap->edit_posts = 'upload_files';
//$wp_post_types['attachment']->cap->delete_posts = 'upload_files';
}
From codex regarding add_cap: