Skip to content

Instantly share code, notes, and snippets.

View zachskaggs's full-sized avatar

Zachary A Skaggs zachskaggs

View GitHub Profile
if (!-e $request_filename)
{ rewrite ^(.*)$ /index.php?q=$1 last; break;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
<?php
function example_disable_newsletter_signup( $form_id ) {
global $ninja_forms_processing;
$form_id = $ninja_forms_processing->get_form_ID();
if ( $form_id == 1 ) {
$opt_in = $ninja_forms_processing->get_field_value( 23 );
if ( $opt_in == 'unchecked' ) {
$ninja_forms_processing->update_form_setting( 'constant_contact_signup_form', false );
}
@zachskaggs
zachskaggs / gist:9d5299c3970604a4b5b5
Last active August 29, 2015 14:21
bad domain msg
<?php
function custom_nf_verify_email_domain(){
global $ninja_forms_processing;
// Gets the ID of the form we are currently processing.
$form_id = $ninja_forms_processing->get_form_ID();
if ($form_id == 13) {
// Get the user submitted value for the field with an ID of 55.
$submitted_email = $ninja_forms_processing->get_field_value( 55 );
// Set the allowed domain that we will accept.
$approved_email = '@gmail.com';
@zachskaggs
zachskaggs / gist:469935ff6c0847494402
Last active August 3, 2016 20:34
Ninja Forms Timestamp
<?php
/*
Plugin Name: Example Plugin
*/
<?php
function my_ninja_forms_date_code(){
//Declare $ninja_forms_processing as a global variable.
global $ninja_forms_processing;
//only process this code on the form ID 1
$form_id = $ninja_forms_processing->get_form_ID();
@zachskaggs
zachskaggs / holiday blocker
Created December 7, 2014 04:40
Holidat blocker
var array = ["2014-12-24","2014-12-25",
"2015-07-04","2015-11-26","2015-12-24","2015-12-25",
"2016-07-04","2016-11-24","2016-12-24","2016-12-25",
"2017-07-04","2017-11-23","2017-12-24","2017-12-25",
"2018-07-04","2018-11-22","2018-12-24","2018-12-25",
"2019-07-04","2019-11-28","2019-12-24","2019-12-25",
"2020-07-04","2020-11-26","2020-12-24","2020-12-25",
"2021-07-04","2021-11-25","2021-12-24","2021-12-25",
"2022-07-04","2022-11-24","2022-12-24","2022-12-25",
"2023-07-04","2023-11-23","2023-12-24","2023-12-25",
@zachskaggs
zachskaggs / renamecsv.php
Created December 2, 2014 19:36
Ninja Forms Rename CSV
<?php
function nf_change_csv_name( $filename ) {
$filename = 'nameyourfilehere';
return $filename;
}
add_filter( 'nf_subs_csv_filename', 'nf_change_csv_name' );
@zachskaggs
zachskaggs / gist:d82acfb62b94cbc181aa
Last active August 29, 2015 14:08
Set hidden field to date
<?php
add_action( 'ninja_forms_pre_process' , 'sn_add_date_to_submission' , 10 );
function sn_add_date_to_submission(){
global $ninja_forms_processing;
$ninja_forms_processing->update_field_value( 9 , current_time( 'm-d-Y' ) );
<?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;

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 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' ) )