Skip to content

Instantly share code, notes, and snippets.

@EvanHerman
Last active October 12, 2015 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanHerman/185f900217f3ecebbbef to your computer and use it in GitHub Desktop.
Save EvanHerman/185f900217f3ecebbbef to your computer and use it in GitHub Desktop.
Easy Forms for MailChimp by YIKES - Pre-populate form field with URL Param shortcode.
<?php
/*
* Add a new custom tag to the 'pre defined tags' section
* @ Change 'tag', 'description' and 'title' to suit your needs.
* @ $available_tags - the default pre-defined tags available out of the box
*/
add_filter( 'yikes-mailchimp-custom-default-value-tags', 'add_new_pre_defined_tags' );
function add_new_pre_defined_tags( $available_tags ) {
// define a new array, with our default tag data (note: to create more than one, simply copy and paste what is below and alter the values)
$available_tags[] = array(
'tag' => '{YIKES_Example}', // tag that will be parsed
'description' => '<h4 class="tooltip-title">Yikes New | <small>{YIKES_Example}</small></h4><hr />' . __( 'This is the description that appears in the tooltip, when hovering on the question mark icon.' , 'text-domain' ), /// tool tip content that appears on hover
'title' => 'YIKES Example' // title of the link (on hover, used for accessibility purposes)
);
return $available_tags; // return the new tags
}
/*
* Process the custom tag, and populate the field with URL Param shortcode
* @$tag - the tag that you would like to parse
* @works only with email, text and number fields
*/
add_filter( 'yikes-mailchimp-process-default-tag', 'process_URL_param_plugin_shortcode_tag' );
function process_URL_param_plugin_shortcode_tag( $tag ) {
// set up a conditional so we only parse the tag we need
if( $tag == '{YIKES_Example}' ) {
return stripslashes( do_shortcode( '[urlparam param="FirstName"]' ) );
}
// return the tag
return $tag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment