Skip to content

Instantly share code, notes, and snippets.

View klhall1987's full-sized avatar

Kenny Hall klhall1987

View GitHub Profile
@klhall1987
klhall1987 / custom.js
Created November 29, 2016 15:42
This Gist shows how to use JS to get and modify form data.
jQuery( document ).ready( function() {
var runCustomJS = Marionette.Object.extend( {
initialize: function() {
this.listenTo( Backbone.Radio.channel( 'form' ), 'render:view', this.editFieldData );
},
/*
* In this function you can do things like:
* modify the form data
jQuery.ajax({
url: nfFrontEnd.adminAjax,
type: 'POST',
data: data,
cache: false,
xhrFields: { withCredentials: true },
success: function( data, textStatus, jqXHR ) {
try {
var response = jQuery.parseJSON( data );
nfRadio.channel( 'forms' ).trigger( 'submit:response', response, textStatus, jqXHR, formModel.get( 'id' ) );
array(22) {
["date_updated"]=>
string(10) "2016-06-21"
["active"]=>
string(1) "1"
["type"]=>
string(8) "webhooks"
["from_name"]=>
string(0) ""
["from_address"]=>
<?php
//Are all these args passed in from Ninja Forms?
//Is the data array build by Ninja Forms?
// I am having trouble figuring out how to correctly use this process function in my actions.php
public function process( $action_settings, $form_id, $data )
{
$list = $action_settings[ 'newsletter_list' ];
$double_opt_in = $action_settings[ 'double_opt_in' ];
$data[ 'actions' ][ 'emma' ][ 'list' ] = $list;
<?php
//Does the string 'members/signup' do? I see you do this quite a bit in mailchimp as well
//I didn't see
$this->response = $this->emma->make_request('members/signup', 'POST', $member_data);
//This is the method you are calling inside the Emma library.
//I'm just trying to get my head wrapped around this concept.
/**
add_action( 'ninja_forms_display_init', 'my_filter_functiontwo', 10 );
function my_filter_functiontwo( $form_id )
{
global $ninja_forms_loading;
if ( 66 == $form_id ) {
$user_info = get_userdata(1);
//Grab the user's first name and update the value of field 1098.
$ninja_forms_loading->update_field_value( 1098, $user_info->first_name );
@klhall1987
klhall1987 / HardlyCasualColorScheme
Created March 24, 2016 13:31
Hardly Casual Slack color scheme
007070 444A47 CF6706 FFFFFF FF7B00 FFFFFF 00FF04 F6FA0C
@klhall1987
klhall1987 / 12716-example.php
Last active February 23, 2016 18:04
An example of using the ninja forms processing variable.
//Hook into ninja forms processing.
add_action( 'ninja_forms_post_process', 'ninja_forms_code', 9999 );
function ninja_forms_code(){
//Declare $ninja_forms_processing as a global variable.
global $ninja_forms_processing;
//Get an array of all user-submitted values:
$all_fields = $ninja_forms_processing->get_all_fields();
@klhall1987
klhall1987 / remove-nf-metaboxs-and-tinymce-buttons.php
Created February 23, 2016 15:35
Removes add form meta boxes and tinyMCE buttons.
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/*
Plugin Name: Remove NF Meta Boxes
Description: Removes add form meta boxes and tinyMCE buttons.
Version: 1.0
Author: Kenny Hall
Author URI: http://kennyinthewild.com
*/
/*This is the function the line of code is in. It starts on line 258 in the current code base.
*The The file path is ../ninja-forms-multi-part/js/dev/ninja-forms-mp-display.js
*You will need to re-minify the js and replace the minified js file located in ../ninja-forms-multi-part/js/min/ninja-forms-mp-display.js
* After you have made the changes.
*/
function ninja_forms_update_progressbar( form_id, current_page ){
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var page_count = mp_settings.page_count;
if( current_page == 1 ){
var percent = 0;