Ninja Forms plugin menu access

Ninja Forms plugin protects all its menu items with ‘manage_options” user capability by default.

Thanks to plugin developers it’s possible to replace default user capability for every menu item using custom filter:

Ninja Forms – ninja_forms_menu_ninja-forms_capability
Dashboard – ninja_forms_admin_all_forms_capabilities
Add New – ninja_forms_admin_add_new_capabilities
Submissions – ninja_forms_admin_submissions_capabilities
Import/Export – ninja_forms_admin_import_export_capabilities
Settings – ninja_forms_admin_settings_capabilities
Get Help – ninja_forms_admin_status_capabilities
Add-Ons – ninja_forms_admin_extend_capabilities

How to use these filters? Look at the example below:

/*
 * Custom capabilities for Ninja Forms admin menu
 */
 
// Ninja Forms
 add_filter('ninja_forms_menu_ninja-forms_capability', 'ninja_forms_menu_get_cap', 10, 1);
 function ninja_forms_menu_get_cap( $cap ) {
     $cap = 'nf_admin_menu';
     return $cap;
 }
 
// Ninja Forms -> Dashboard 
 add_filter('ninja_forms_admin_all_forms_capabilities', 'ninja_forms_dashboard_get_cap', 10, 1);
 function ninja_forms_dashboard_get_cap( $cap ) {
     $cap = 'nf_admin_menu';
     return $cap;
 }
 
// Ninja Forms -> Add New 
 add_filter('ninja_forms_admin_add_new_capabilities', 'ninja_forms_add_new_get_cap', 10, 1);
 function ninja_forms_add_new_get_cap( $cap ) {
     $cap = 'nf_add_new';
     return $cap;
 }
 
// Ninja Forms -> Submissions 
 add_filter('ninja_forms_admin_submissions_capabilities', 'ninja_forms_submissions_get_cap', 10, 1);
 function ninja_forms_submissions_get_cap( $cap ) {
     $cap = 'nf_submissions';
     return $cap;
 }
 
// Ninja Forms -> Settings
 add_filter('ninja_forms_admin_settings_capabilities', 'ninja_forms_settings_get_cap', 10, 1);
 function ninja_forms_settings_get_cap( $cap ) {
     $cap = 'nf_settings';
     return $cap;
 }
 
// Ninja Forms -> Get Help 
 add_filter('ninja_forms_admin_status_capabilities', 'ninja_forms_status_get_cap', 10, 1);
 function ninja_forms_status_get_cap( $cap ) {
     $cap = 'nf_status';
     return $cap;
 }
 
// Ninja Forms -> Add-Ons 
 add_filter('ninja_forms_admin_extend_capabilities', 'ninja_forms_extend_get_cap', 10, 1);
 function ninja_forms_extend_get_cap( $cap ) {
     $cap = 'nf_addons';
     return $cap;
 }

Code above was tested with WordPress 5.3.2 and Ninja Forms 3.4.24.1

Share