I created a user Wordpress user with its capabilities: this user can only read, edit and delete messages of a custom message type (called a recipe).
I give this user a role to download the file, because when the user writes an entry in the recipe, you can add media to your article.
Downloading the file works fine in the media manager (not in the iframe media file, because the conditions for editing attachments have the edit_post role). In fact, this user with custom roles cannot edit and delete attachments (I cannot give him the roles edit_posts and delete_posts, because there are many other custom message types managed by the site administrator on this site
I know the attachment is post post_type, but how can I assign features to edit and delete its media?
Search I found this hack to change the default attachment capabilities, but I don't think this is the right way
global $wp_post_types;
$wp_post_types['attachment']->cap->edit_post = 'upload_files';
$wp_post_types['attachment']->cap->read_post = 'upload_files';
$wp_post_types['attachment']->cap->delete_post = 'upload_files';
thanks in advance
Marco source
share