Skip to content

Instantly share code, notes, and snippets.

<?php
function bust_godaddy_caching( $url, $form_id ) {
$new_url = add_query_arg( array( 'nocache' => 1 ), $url );
return $new_url;
}
add_filter( 'ninja_forms_ajax_url', 'bust_godaddy_caching', 10, 2 );
<?php
function my_custom_nf_action( $types ) {
$types['my_action'] = PATH_TO_MY_ACTION_CLASS_FILE;
return $types;
}
add_filter( 'nf_notification_types', 'my_custom_nf_action' );
@kstover
kstover / example-action.php
Created August 13, 2015 19:13
Creating a Custom Action for Ninja Forms
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class for our custom action type.
*
* @package Ninja Forms
* @subpackage Classes/Actions
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.8
*/
<?php
function nf_test_exclude_plugins( $plugins ) {
if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX || !isset( $_REQUEST['action'] ) || ( 'nf_output_field_settings_html' != $_REQUEST['action'] && 'ninja_forms_new_field' != $_REQUEST['action'] ) ) return $plugins;
foreach( $plugins as $key => $plugin ) {
if ( false !== strpos( $plugin, 'ninja-forms' ) ) continue;
unset( $plugins[$key] );
}
/**
* Force the cookie expiration variant time to 23 minutes
*
* @access public
* @since 2.9.18
* @param int $exp Default expiration (1 hour)
* @return int
*/
public function set_expiration_variant_time( $exp ) {
return 60 * 23;
@kstover
kstover / NF-Admin-Modal.html
Last active August 29, 2015 14:21
Ninja Forms - Using the NF Admin Modal to create custom admin modal dialogs
<div class="custom-message" style="display:none;"> <!-- adding display:none; will keep the element from flashing on load. -->
<?php _e( 'This setting will COMPLETELY remove anything Ninja Forms related upon plugin deletion. This includes SUBMISSIONS and FORMS. It cannot be undone.', 'ninja-forms' ); ?>
</div>
<div class="custom-message-buttons" style="display:none;"> <!-- the buttons div defines the bottom of the modal.-->
<div id="nf-admin-modal-cancel"> <!-- nf-admin-modal-cancel is the class that aligns the button to the left. -->
<a class="submitdelete deletion modal-close" href="#">Cancel</a>
</div>
<div id="nf-admin-modal-update"> <!-- nf-admin-modal-update is the class that aligns the button to the right. -->
<a class="button-primary" href="#">Continue</a>
</div>
@kstover
kstover / export-filtered-subs.php
Last active August 29, 2015 14:18
Exporting filtered submissions using the Ninja Forms Submissions API
<?php
// Build an array that we can use for filtering our submitted data.
$args = array(
// fields is a key in our associative array that means we're looking for field values.
'fields' => array(
// 1 represents our field id and 'Kevin' represents the value we're looking to match.
1 => 'Kevin',
// If you want to filter by multiple fields, you'd add them here.
// 2 => 'checked'
),
@kstover
kstover / 0_reuse_code.js
Created June 15, 2014 21:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function ninja_forms_remove_csv_values( $value_array, $sub_id_array ) {
foreach( $value_array as $x => $value ) {
unset( $value_array[$x][0] );
unset( $value_array[$x][1] );
}
array_values( $value_array );
return $value_array;
}
add_filter( 'ninja_forms_export_subs_value_array', 'ninja_forms_remove_csv_values', 15, 2 );
function test_product() {
$NF_Extension_Updater = new NF_Extension_Updater( 'Test Product', '1.0' );
}
add_action( 'admin_init', 'test_product' );