Skip to content

Instantly share code, notes, and snippets.

@New0
Last active November 2, 2021 12:07
Show Gist options
  • Save New0/06d5b7664a8cfbb256a13bc68de0aa98 to your computer and use it in GitHub Desktop.
Save New0/06d5b7664a8cfbb256a13bc68de0aa98 to your computer and use it in GitHub Desktop.
Allow editors to manage Ninja Forms > 3.6 Submissions
<?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;
}
@New0
Copy link
Author

New0 commented Oct 29, 2021

Hello @Banilancer you can use this code in the functions.php file of your (child-) theme or in a custom plugin if you add the plugin header information at the top of this file and upload it in the plugins folder of your WP installation.

@lujo76
Copy link

lujo76 commented Nov 2, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment