• Only works for admins out of the box, and there is no way to edit this in the plugin itself.

    I had to manually edit this.
    Adding the following code allowed me to enable editors to use the plugin as well.

    function squazz_change_ninja_forms_capabilities_filter( ) {
       return 'edit_others_posts';
    }
    add_filter( 'ninja_forms_admin_menu_capabilities', 'squazz_change_ninja_forms_capabilities_filter' ); // Show Ninja Forms menu
    add_filter( 'ninja_forms_admin_add_new_capabilities', 'squazz_change_ninja_forms_capabilities_filter' ); // Show "Add New" submenu
    add_filter( 'ninja_forms_admin_all_forms_capabilities', 'squazz_change_ninja_forms_capabilities_filter' ); // Show "All Forms" submenu
    add_filter( 'ninja_forms_admin_submissions_capabilities', 'squazz_change_ninja_forms_capabilities_filter' ); // Show "Submissions" submenu
    add_filter( 'ninja_forms_admin_import_export_capabilities', 'squazz_change_ninja_forms_capabilities_filter' ); // Show "Import / Export" submenu
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author James Laws

    (@jameslaws)

    Thank you for your review. I just wanted to give some background on why the capabilities really aren’t a problem.

    Consider fist that the most plugins that have settings generally only give those permissions to administrators. This is the most common default position as most people building a WordPress site are administrators on their own sites.

    Also, consider that there are whole plugins devoted only to the purpose of changing permissions within the WordPress admin. Think Role Scoper and the like. These have huge settings pages to configure this and is very much outside the realm of Ninja Forms specifically.

    There are occasions where someone might want to give permissions to another capability or role. For instance if you are building a site for a client and you want them to be able to create and edit forms but not have access to other admin areas. Of course if you are this person, adding a filter is super easy as you’ve demonstrated above.

    Now what about the scenario where you want even more fine tuned control. Maybe you want admins to be able to adjust plugin settings, Editors to create forms, and authors to manage submissions, or any other combination. That is now equally as easy with the filter method but the settings for this would become heavy handed because we can’t account for every possible situation or even more so custom implementations.

    In the end this was a decision in favor of flexibility and not a limitation.

    I hope this helps at the very least to explain why the system works like it does. Again, thank you for your honest review, We really do appreciate it.

    Thread Starter Squazz

    (@squazz)

    Thank you for the very long response. As I see why you have done it, I woul stille like to see something like it is seen with NextGen Galleries, where each action/menu can be set to a “lowest user”.

    For each of the filters I have set up, one could set up a option where site admins with the click of a mouse could choose the lowest user who should have acces to say “ninja_forms_admin_submissions_capabilities”.

    In the case with filters, I would have to create a function for each user roler that I wanted to edit.

    The above is simple because it only is for editors and admins. But if I want to fine tune it even further I would have to create a new function.

    If I have to choose between a option-menu inside the plugin, or the filter approach then there is no question for me.

    Take into account that I had to search for some time to find the “right” solution to the problem. I have only been working with WordPress for 4 months, so A LOT has to be learned. And I am a developer.
    What about small “admins” or private users who would like to do something like the above, but doesn’t know anything about code?

    They will have to hire a programmer to do this “simple” task for them.

    Then again, I could follow your way of doing things, and just create a plugin for it, and then hope you guys would sell it for me at your site ?? The question is, should people really need to pay for stuff like this?

    Plugin Author James Laws

    (@jameslaws)

    We help those people every day. Many are completely non coders and they have no trouble copy and pasting the code for their use case. Additionally, while these filters are easy to implement on a one time basis, they are equally easy to adjust programmatically on the fly.

    All that being said we are simply respecting the WordPress development philosophy of “Decisions not options” while defining out defaults to the most common use case and providing the flexibility to change those defaults if necessary.

    We’re sorry you find this problematic and do appreciate the feedback even if we might see it differently. We will most definitely consider your point of view in the future.

    Hi
    I too would like to extend dashboard access to Ninja forms to my Editors. Thanks Squazz for the code snippet, but you don’t say where you deployed this code? Could you expand a bit, please.

    I agree with the Squazz that a basic option within the plugin to control its visibility in the dashboard would be useful to non-coders like myself.

    The finer-grained control that James eludes to is, I’m sure very valuable in the rarified atmosphere inhabited by folk who are comfortable hacking plugins, but I’m not one of them. Nor do I need that level of control in my situation.

    I just want to maintain a divide in our site’s management: The admins (me) keep the site running, the heads of department (editors) write and maintain the content. That’s a fundamental of CMS, right?

    At the mo I’ve had to promote some folk to Admin, and that’s not a good thing in the long run.

    Thanks, David.

    Thread Starter Squazz

    (@squazz)

    @dmajwool you have to add it in functions.php, as you do with almost all filters you write yourself ??

    I wrote more about this on my danish blog: https://squazz.dk/teknologi/ninja-forms-capabilities/

    It’s in danish, but a google translated version is here: https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fsquazz.dk%2Fteknologi%2Fninja-forms-capabilities%2F&edit-text=

    Sometime in the future, I plan to translate everything to english myself, but I havn’t got there yet :/

    Thank you Squazz,

    I searched some more and found that the topic is covered, slightly obliquely across a couple of pages on the Ninja website.

    I followed instructions from the below website pages and now have editors able to access Ninja Forms.

    https://wpninjas.com/how-to-create-a-simple-wordpress-plugin/

    https://docs.ninjaforms.com/customer/portal/articles/1981035-general-guidance-change-who-can-access-ninja-forms-in-the-admin?b_id=9172

    1.) FTP login to your website and create the folder ‘wp-content/plugins/my_custom_change_ninja_forms_all_forms_capabilities_filter’

    2.) In that folder create an empty file ‘my_custom_change_ninja_forms_all_forms_capabilities_filter.php’

    3.) In that empty file, paste at the top…

    <?php
    /*
    Plugin Name: my_custom_change_ninja_forms_all_forms_capabilities_filter
    */

    4.) …and under that, paste this code from the 2nd Ninja link above

    <?php
    // To give Editors access to the ALL Forms menu
    function my_custom_change_ninja_forms_all_forms_capabilities_filter( $capabilities ) {
        $capabilities = "edit_pages";
        return $capabilities;
    }
    add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'my_custom_change_ninja_forms_all_forms_capabilities_filter' );
    add_filter( 'ninja_forms_admin_all_forms_capabilities', 'my_custom_change_ninja_forms_all_forms_capabilities_filter' );
    // To give Editors access to ADD New Forms
    function my_custom_change_ninja_forms_add_new_capabilities_filter( $capabilities ) {
        $capabilities = "edit_pages";
        return $capabilities;
    }
    add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'my_custom_change_ninja_forms_add_new_capabilities_filter' );
    add_filter( 'ninja_forms_admin_add_new_capabilities', 'my_custom_change_ninja_forms_add_new_capabilities_filter' );
    
    /* To give Editors access to the Submissions - Simply replace ‘edit_posts’ in the code snippet below with the capability
    that you would like to attach the ability to view/edit submissions to.Please note that all three filters are needed to
    provide proper submission viewing/editing on the backend!
    */
    function nf_subs_capabilities( $cap ) {
        return 'edit_posts';
    }
    add_filter( 'ninja_forms_admin_submissions_capabilities', 'nf_subs_capabilities' );
    add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'nf_subs_capabilities' );
    add_filter( 'ninja_forms_admin_menu_capabilities', 'nf_subs_capabilities' );
    
    // To give Editors access to the Inport/Export Options
    function my_custom_change_ninja_forms_import_export_capabilities_filter( $capabilities ) {
        $capabilities = "edit_pages";
        return $capabilities;
    }
    add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'my_custom_change_ninja_forms_import_export_capabilities_filter' );
    add_filter( 'ninja_forms_admin_import_export_capabilities', 'my_custom_change_ninja_forms_import_export_capabilities_filter' );
    
    // To give Editors access to the the Settings page
    function my_custom_change_ninja_forms_settings_capabilities_filter( $capabilities ) {
        $capabilities = "edit_pages";
        return $capabilities;
    }
    add_filter( 'ninja_forms_admin_parent_menu_capabilities', 'my_custom_change_ninja_forms_settings_capabilities_filter' );
    add_filter( 'ninja_forms_admin_settings_capabilities', 'my_custom_change_ninja_forms_settings_capabilities_filter' );

    5.) Go to your WordPress Dashboard Plugins page and see that there is now a new plugin listed – called ‘my_custom_change_ninja_forms_settings_capabilities_filter’

    6.) Activate the plugin by clicking the Activate link under its name.

    That should be it. Editors should now see the Forms widgets in the dashboard.

    Hope this helps someone, Cheers, David.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Works, but there is capabilities problems’ is closed to new replies.