Registering Plugin Settings

Ninja Forms THREE provides a Settings submenu page for registering plugin settings for both the main plugin as well as add-ons. Settings registered with this system will be displayed and saved by Ninja Forms automatically. Creating a separate setting submenu for an add-on will require developing your own process for displaying, processing, and saving settings. Add-ons requiring heavy customization for plugin settings are free to create a new submenu page, but basic settings are easily handled by Ninja Forms.

Register Plugin Settings

Individual settings can be added to the master $settings array, underneath a settings group array key. For example:

Settings Groups 1

Setting A

Setting B

Settings Group 2

Setting C

Settings are configured following the same format as Action Settings and Field Settings. Refer to the Settings Configuration documentation for an example list of setting properties, with descriptions. Note: not all properties are supported.

Register Settings Groups

Settings are registered underneath a setting group. A new Settings Group can be created by filtering the $groups array.

Defining a new Settings Group requires a unique id (which should match the array key) and a translatable label.

Each Settings Group is rendered as a metabox on the Ninja Forms Settings submenu page in the WordPress Admin.

Checking Setting Values

Hook: ninja_forms_check_setting_{$id}

Example: ninja_forms_check_setting_example_setting

Each time the Ninja Forms Settings submenu page is loaded, a WordPress filter hook is fired for every setting. This filter hook allows for add-ons to check (validate) the value of each setting. When checking or validating a setting’s value, the setting can be updated with errors before being passed back through the filter.

Errors added to a setting will display an Admin Notice at the top of the Settings submenu page, which links to an inline error displayed below the appropriate setting.

An error can be added as a translatable string to the $setting[ ‘error’ ] array item (Note: array key is NOT required, only the value).

Updating Setting’s Values

Hook: ninja_forms_update_setting_{$id}

Example: ninja_forms_update_setting_example_setting

Before a setting’s value is saved, the value is first sanitized, the filtered.

Saving Setting’s Values

Hook: ninja_forms_save_setting_{$id}

Example: ninja_forms_save_setting_example_setting

After a setting’s value has been saved, a WordPress Action Hook is triggered, passing the setting’s value, for further processing.

Full Code Example

The following example organizes all of the add-on related Ninja Forms Settings hooks inside of a dedicated plugin settings class:

Everything you need to build everything you want

Quick Start Guides

I want to pre-fill form fields

I want to integrate with a third party service

I want to connect to a third-party like Slack, Trello, Mail Chimp, etc. using their API. How do I hook into the Ninja Forms processing system to send data to those services?

I want to create a custom field for my users

I need to collect specific data or present fields to a user that aren’t native to Ninja Forms. How can I create something that will be reusable and won’t require me to mess with the code once it’s written?

I want to display submission information on the front-end

I’d like to display submissions on the front-end for my users.

I want to send submissions to another database

I have another database that I would like to store Ninja Forms data in.

Translation Ready

Want Ninja Forms in another language? The framework is translation-ready, making it as easy as possible for you. Special incentives for translators who want to join the team.