Thread Starter
niska
(@niska)
I’m sorry, there seems to be a problem with permissions. I’m using the User Role Editor and have made a custom permission “flamingo”. Users that have this permission should be able to view the data from the forms.
I have also removed the map_meta_cap filter and added a custom one, like this:
remove_filter( 'map_meta_cap', 'flamingo_map_meta_cap' );
add_filter( 'map_meta_cap', 'mycustom_flamingo_map_meta_cap', 9, 4 );
function mycustom_flamingo_map_meta_cap( $caps, $cap, $user_id, $args ) {
$meta_caps = array(
'flamingo_edit_inbound_messages' => 'flamingo',
'flamingo_delete_inbound_message' => 'flamingo',
'flamingo_delete_inbound_messages' => 'flamingo',
'flamingo_spam_inbound_message' => 'flamingo',
'flamingo_unspam_inbound_message' => 'flamingo',
'flamingo_edit_outbound_message' => 'flamingo',
'flamingo_edit_outbound_messages' => 'flamingo',
'flamingo_delete_outbound_message' => 'flamingo',
);
$caps = array_diff( $caps, array_keys( $meta_caps ) );
if ( isset( $meta_caps[$cap] ) )
$caps[] = $meta_caps[$cap];
return $caps;
}
The problem is that users that have “flamingo” can not view the messages. They only see the subject, name and email.
Not sure what I’m doing wrong.
Please help.
-
This reply was modified 7 years, 3 months ago by
niska.
In the current version of Flamingo there are 12 meta capabilities defined.
https://plugins.trac.ww.wp.xz.cn/browser/flamingo/tags/1.9/includes/capabilities.php
You only have 8 of them and the rest are lost.
To avoid such issues happening again, use the filter in the right way. See https://ww.wp.xz.cn/support/topic/granting-access-to-the-editor-role/
Thread Starter
niska
(@niska)
Thanks for your reply.
I’ve tried setting all 12 capabilities to my custom permission “flamingo”, but that didn’t make any difference.
I don’t want everyone with edit_pages capability to view the messages so I can’t copy/paste your example code…
Any ideas what I’m doing wrong?
Thread Starter
niska
(@niska)
I’m sorry, it was my misstake. I forgot to add ‘flamingo_edit_inbound_message’ => ‘flamingo’.
My current code seems to be working now, except I’m unable to edit the data. Is data supposed to be editable?
My code:
remove_filter( 'map_meta_cap', 'flamingo_map_meta_cap' );
add_filter( 'map_meta_cap', 'mycustom_flamingo_map_meta_cap', 9, 4 );
function mycustom_flamingo_map_meta_cap( $caps, $cap, $user_id, $args ) {
$meta_caps = array(
'flamingo_edit_inbound_message' => 'flamingo',
'flamingo_edit_inbound_messages' => 'flamingo',
'flamingo_delete_inbound_message' => 'flamingo',
'flamingo_delete_inbound_messages' => 'flamingo',
'flamingo_spam_inbound_message' => 'flamingo',
'flamingo_unspam_inbound_message' => 'flamingo',
'flamingo_edit_outbound_message' => 'flamingo',
'flamingo_edit_outbound_messages' => 'flamingo',
'flamingo_delete_outbound_message' => 'flamingo',
);
$caps = array_diff( $caps, array_keys( $meta_caps ) );
if ( isset( $meta_caps[$cap] ) )
$caps[] = $meta_caps[$cap];
return $caps;
}