Home › Forums › Backend Issues (wp-admin) › Save Meta for ACF Pro media don't work for non-admin
Hi
I made a custom post type with ACF fields: Media, Gallery.
'capability_type' => 'artiste',
'map_meta_cap' => true,
'capabilities' => array(
// meta caps (don't assign these to roles)
'edit_post' => 'edit_artiste',
'read_post' => 'read_artiste',
'delete_post' => 'delete_artiste',
// primitive/meta caps
'create_posts' => 'create_artistes',
// primitive caps used outside of map_meta_cap()
'edit_posts' => 'edit_artistes',
'edit_others_posts' => 'manage_artistes',
'publish_posts' => 'publish_artistes',
'read_private_posts' => 'read',
// primitive caps used inside of map_meta_cap()
'read' => 'read',
'delete_posts' => 'delete_artistes',
'delete_private_posts' => 'delete_private_artistes',
'delete_published_posts' => 'delete_published_artistes',
'delete_others_posts' => 'manage_artistes',
'edit_private_posts' => 'edit_artistes',
'edit_published_posts' => 'edit_artistes'
)
On this post type, I create a custom role.
function manage_artiste_capabilities() {
$admin = get_role('administrator');
$galerie = get_role('galerie');
$caps = array(
'create_artistes',
'edit_artistes',
'publish_artistes',
'delete_artistes',
'delete_published_artistes',
'manage_artistes',
);
foreach($caps as $cap) {
$admin->add_cap($cap);
}
$admin->remove_cap('special_galerie');
// basique
$galerie->add_cap('upload_files');
// artistes
$galerie->add_cap('create_artistes');
$galerie->add_cap('edit_artistes');
$galerie->add_cap('publish_artistes');
$galerie->add_cap('delete_artistes');
}
The admin can add some meta for normal field ou custom (with ACF). The meta are saved and updated
For the custom role, he can add some meta (normal media fields or custom with ACF) but the saved or update method failed.
I made a test for an other post type, on the same website. This one use the normal Editor with built in media. In this case, everything works fine.
Have you an idea? Thanks
WordPress 4
ACF PRO: 5.1.0
That’s a WordPress feature which make the “bug”.
With custom roles, the users can’t edit media. You need to add cap for this role.
This tutorial by Simon Wheatley explain the process.
The topic ‘Save Meta for ACF Pro media don't work for non-admin’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.