Skip to content

Instantly share code, notes, and snippets.

View zachskaggs's full-sized avatar

Zachary A Skaggs zachskaggs

View GitHub Profile
@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' ) );
@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 / 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 / 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 / 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';
<?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 );
}
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
/*
Template Name: Ticket Consignment Standard
*/
get_header(); ?>
<?php if ( have_posts() ) : ?>
<form role="search" method="get" class="searchform" action="<?php echo home_url( '/' ); ?>">
<input type="text" name="s" id="s" value="Search for tickets" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />
<input type="hidden" name="post_type" value="ticket" />
<!--1. Documentation should include the simplest, most concise way for a new user to run your addon successfully. -->
<!--2. Use the simplest use case possible for each feature, broken down into easy to digest steps. -->
<!--3. As a general rule of thumb, no more than two mouse clicks should take place in each distinct step (a choice and save/action, for example).-->
<!--4. If you plugin can handle fringe, advanced use cases you may document these in an "Advanced" section after the simple setup.-->
<!--5. Every single option, filter, or shortcode in your plugin should be documented at the END of the documentation, after the simple set up. -->
<!-- -You may reference it in the above docs and create an anchor link to your definition, but do not expound on them in the body.-->
<a name="top"></a>
<ul>
var PHPUnserialize = require('php-unserialize');
var mysql = require('mysql');
connection.query('SELECT * FROM wp_ninja_forms where id =2', function(err, rows, fields) {
if (err) throw err;
//console.log('The solution is: ', rows[0].solution);
for (var i in rows) {
console.log(rows[i].data);
var formObject = PHPUnserialize.unserialize(rows[i].data);
console.log(formObject);