Last active
November 2, 2021 12:07
-
-
Save New0/06d5b7664a8cfbb256a13bc68de0aa98 to your computer and use it in GitHub Desktop.
Allow editors to manage Ninja Forms > 3.6 Submissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter hook used in the API route permission callback to retrieve submissions | |
* | |
* return bool as for authorized or not. | |
*/ | |
add_filter( 'ninja_forms_api_allow_get_submissions', 'nf_define_permission_level', 10, 2 ); | |
add_filter( 'ninja_forms_api_allow_delete_submissions', 'nf_define_permission_level', 10, 2 ); | |
add_filter( 'ninja_forms_api_allow_update_submission', 'nf_define_permission_level', 10, 2 ); | |
add_filter( 'ninja_forms_api_allow_handle_extra_submission', 'nf_define_permission_level', 10, 2 ); | |
add_filter( 'ninja_forms_api_allow_email_action', 'nf_define_permission_level', 10, 2 ); | |
function nf_define_permission_level() { | |
$allowed = \current_user_can("delete_others_posts"); | |
return $allowed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks New0 and ouija for this help - this update has really caused some issues for my clients situation - following on from Banilancer, can/do I add the...
// Must use all three filters for this to work properly.
add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'nf_subs_capabilities' ); // Parent Menu
add_filter( 'ninja_forms_admin_all_forms_capabilities', 'nf_subs_capabilities' ); // Forms Submenu
add_filter( 'ninja_forms_admin_submissions_capabilities', 'nf_subs_capabilities' ); // Submissions Submenu
function nf_subs_capabilities( $cap ) {
return 'edit_posts'; // EDIT: User Capability
}
...to the functions.php file too. I'm not having much luck as yet. Also are the User_capability and current_user_can related?