This is an Advanced Custom Field custom field to select one or many Ninja Forms.
This provides a field that lets you select from a list of active Ninja Forms.
This add-on will work with:
- ACF version 5
This add-on can be treated as both a WP plugin and a theme include.
Plugin
- Copy the 'ninja-forms-acf-field' folder into your plugins folder
- Activate the plugin via the Plugins admin page
Include
- Copy the 'ninja-forms-acf-field' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
- Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-gravity_forms.php file)
include_once('acf-ninja_forms.php');
The field lets you pick one or many fields.
The data returned is either a Form settings array or, for multiple values, an object of Form settings arrays.
The following example will work with single or multiple form entries.
<?php
$ninja_form = get_field('your_form_field');
if( function_exists( 'ninja_forms_display_form' ) && is_array( $ninja_form ) ){ // Ninja forms 2.x
ninja_forms_display_form( $ninja_form['id'] );
} elseif( function_exists( 'ninja_forms_display_form' ) && is_object( $ninja_form ) ){ // Ninja forms 2.x
foreach ($ninja_form as $form) {
ninja_forms_display_form( $form['id'] );
}
} elseif( class_exists( 'Ninja_Forms' ) && is_array( $ninja_form ) ){ // Ninja forms 3.x
Ninja_Forms()->display( $ninja_form['id'] );
} elseif( class_exists( 'Ninja_Forms' ) && is_object( $ninja_form ) ){ // Ninja forms 3.x
foreach ($ninja_form as $form) {
Ninja_Forms()->display( $form['id'] );
}
}
?>
You can find out more about the ninja forms functions to embed a form or form data on a page in their documentation
Since this is a drop-in plugin, we will make sure that versioning happens according to the main plugin.
Thanks to Adam Pope of Storm Consultancy for the Gravity Forms ACF Field plugin which this is based on.
And in turn, Lewis Mcarey for the Users Field ACF add-on on which the Gravity Forms ACF field was based.