Skip to content

Instantly share code, notes, and snippets.

@zachskaggs
zachskaggs / gist:5eb3e87ee864806fbb5d
Last active August 29, 2015 14:05
Change email user values title Ninja Forms.
<?php
function nf_change_admin_email_title( $title ) {
global $ninja_forms_processing;
if ( 1 == $ninja_forms_processing->get_form_ID() ) {
$title = 'Here is some stuff';
}
return $title;
}
add_filter( 'nf_email_user_values_title', 'nf_change_admin_email_title' );
<?php
function nf_change_uploads_dir( $upload_dir ) {
global $ninja_forms_processing;
$upload_dir = '/my/directory/here';
return $upload_dir;
}
add_filter( 'ninja_forms_uploads_dir', 'nf_change_uploads_dir' );
@zachskaggs
zachskaggs / gist:81febf738f33080cdaa7
Last active August 29, 2015 14:05
To replace checked/unchecked values in user emails to yes/no
<?php
function nf_change_user_email_value( $email ) {
$original = array('checked','unchecked')
$replace = array('yes','no')
return str_replace( $original, $replace, $email );
}
add_filter( 'ninja_forms_email_user_value', 'nf_change_user_email_value' );
@zachskaggs
zachskaggs / gist:f65c21cab784b467311a
Created August 21, 2014 19:40
Ninja Forms Append Error Messages
function customnf_success_msg( $content ) {
global $ninja_forms_processing;
if( ! isset( $ninja_forms_processing ) )
return $content;
$success = '';
if( $success = $ninja_forms_processing->get_all_success_msgs() ) {
foreach( $success AS $id => $msg ) {
$success .= $msg . '<br />';
<?php
/*
Plugin Name: Ninja Forms Logged Out Hidden Form Error
Plugin URI: http://wpninjas.net
Description: This plugin adds an error message letting a user know they must log in to see forms with the "User must be logged in to see forms" option checked
Version: 1.0
Author: WPN Zach
Author URI: http://zachskaggs.com
*/
function nf_logged_out_display_msg( $form_id ) {
@zachskaggs
zachskaggs / gist:de1783feaebb70461182
Created September 12, 2014 16:17
Ninja Forms Field Chunk Wraps
<?php
function example_group_open_wrap( $field_id, $data ) {
if( $data['class'] == 'class1' ) {
echo '<div class="my-fields-group">';
}
}
add_action ( 'ninja_forms_display_before_field', 'example_group_open_wrap', 1, 2 );
function example_group_close_wrap( $field_id, $data ) {
if( $data['class'] == 'class2' ) {
@zachskaggs
zachskaggs / gist:1eb33e4afb2ad2384ecf
Created September 26, 2014 20:03
Update ninja forms CC field labels
<?php
function ninja_forms_credit_card_number_desc_change_func ( $string ) {
$string = 'change this';
return $string;
}
function ninja_forms_credit_card_number_label_change_func ( $string ) {
$string = 'change this';
return $string;
<?php
function my_cool_filter( $setting, $setting_name, $id ) {
global $ninja_forms_processing;
// Bail if we aren't filtering the to setting
if ( 'to' != $setting_name )
return $setting;
// Bail if our notification's setting name isn't admin_email
if ( 'admin_email' != Ninja_Forms()->notification( $id )->get_setting( 'name' ) )

Keybase proof

I hereby claim:

  • I am wpnzach on github.
  • I am zachskaggs (https://keybase.io/zachskaggs) on keybase.
  • I have a public key whose fingerprint is 2754 C25B A320 A7D5 0160 93BE B7B5 8BC1 AB64 B716

To claim this, I am signing this object:

<?php
function nf_change_user_csv_value( $user_value , $field_id ) {
// Grab the field.
$field = ninja_forms_get_field_by_id( $field_id );
// Check if this is a checkbox.
if ( $field['type'] == '_checkbox') { // If this is a checkbox, change the value
// checking value of user value, assigning new value
if ( $user_value == 'checked' ) {
$user_value = 1;