Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor yikesinc

    (@yikesinc)

    Hello MauriceDz,

    Many of the hooks and filters changed in the new version.

    We have documentation in our Knowledge Base.

    In the meantime Evan will review the code you posted and see if it can be altered to work.

    Thank you for your patience!

    Plugin Author Evan Herman

    (@eherman24)

    Hi MariceDz,

    The filter has actually changed from ‘yikes_mailchimp_default_value_tag’ to ‘yikes-mailchimp-custom-default-value-tags’. I am going to write up a quick example for you, and I will post it here for you.

    Thanks!
    Evan

    Plugin Author Evan Herman

    (@eherman24)

    Hi MauriceDz,

    After looking into your inquiry and setting up a few tests, I’ve come up with a reasonable example for you to implement.

    I’ve created a gist with all of the necessary code you need, and a few comments to explain what is going on.

    https://gist.github.com/EvanHerman/36dfdb1bb3784ac00459

    You can copy and paste the code directly to the bottom of your themes functions.php and you’ll see the new tag {YIKES_Example} show up in the dashboard alongside the other ones.

    Let us know how that works out for you as I’d be interested to see your implementation.

    Thanks for your patience!

    Evan

    Thanks,
    Evan

    Thread Starter Mr Sprezzatura

    (@mauricedz)

    Hey Evan, that’s super helpful!

    I’ve pasted the same exact new code and the new tag appeared on the list.
    I cannot test the actual pre-population because we don’t have a log in system on our website.

    What I’m specifically trying to do is pre-populate the forms using the WP plugin URL Params.

    The problem with all the MailChimp form plugins I’ve come across with is that they don’t give me any control over the HTML. And that’s crucial because of the way the shortcodes are treated in HTML attributes since WP 4.2.3 update:

    Starting in the WordPress 4.2.3 security auto-update, you can no longer include shortcodes in HTML attributes. Previous to this WordPress update, you could set a field value like this: <input type=”text” name=”firstname” value=”[urlparam param=’FirstName’]”>. Now you have to set it like this: <input type=”text” name=”firstname” [urlparam attr=”value” param=’FirstName’]> or [urlparam htmltag=”input” type=”text” name=”firstname” attr=”value” param=”FirstName” /]. If you are still using this shortcode the old way, unfortunately, WordPress simply won’t process the shortcode and will return back the full shortcode text unprocessed.

    Would it be possible to do something like this via PHP or other means in your plugin? FYI, I don’t know PHP, but I know basic HTML.

    Your help is much appreciated!
    If more Plugin Authors responded that fast and were so helpful as you are, the world would be a better place 🙂

    Plugin Contributor yikesinc

    (@yikesinc)

    Aw, thank you for the kind words. We really appreciate it.

    Evan is at a conference today, but he will answer you as soon as he can.

    Thank you!

    Thread Starter Mr Sprezzatura

    (@mauricedz)

    I see Evan responding to other issue threads, but not this one. Perhaps that’s because it’s marked as “resolved”?

    Please help! I don’t know whether I should be putting hope in making it work with this plugin or building an HTML MailChimp form from scratch.

    Plugin Author Evan Herman

    (@eherman24)

    Hi MauriceDz,

    Sorry I didn’t get back to this thread i wasn’t receiving notifications any longer because it was marked as resolved.

    To answer your question, you should be able to use any shortcodes to prepopulate the form using the tags we have mentioned above.

    Is the query string in the URL the same each time? If so I can provide you with code to grab the data out of the URL without the need for an additional plugin.

    Either way, can you provide me a specific short code example you would like to populate a field with and I can provide you some sample code on how you might achieve what you’re after.

    Thanks,
    Evan

    Thread Starter Mr Sprezzatura

    (@mauricedz)

    I’m just really afraid that the HTML code rendered on the website will look like <input type=”text” name=”firstname” value=”[shortcode]”>, and in this instance the URL Params shortcodes, or any other shortcodes for that matter, won’t work.

    Is the query string in the URL the same each time?

    You mean if it’s going to have the same structure? If so, then yes. I’m just trying to pre-populate 2, maybe 3 fields. Most people will visit that page through the custom URL, but some might somehow find it/go to it without any URL customization.

    Let’s say I’d just want to use the shortcode [urlparam param=’FirstName’].

    Thank you so much for your help! We can’t wait to get our referral campaign going!

    Plugin Author Evan Herman

    (@eherman24)

    Hi MauriceDz,

    I am putting together a code example for you now. I’ll report back here shortly with some code for you.

    Thanks,
    Evan

    Plugin Author Evan Herman

    (@eherman24)

    Hi MauriceDz,

    Feel free to use the follow snippet:
    https://gist.github.com/EvanHerman/185f900217f3ecebbbef

    You’ll want to add that to the bottom of functions.php (without the <?php at the top of the snippet).

    I tested with a URL parameter called FirstName, and things seem to be working well on my end.

    Let us know if that helps out!

    Thanks,
    Evan

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    🏳️‍🌈 YIKES, Inc. Co-Owner

    Hi MauriceDz,

    Any luck? Let us know.

    Thanks!
    -Tracy

    Thread Starter Mr Sprezzatura

    (@mauricedz)

    That worked, thanks a lot! You guys are really great.

    However, when I added the same code but with all the “YIKES_Example” changed (I want to pre-populate 2 different fields), I got an error:

    Fatal error: Cannot redeclare add_new_pre_defined_tags() (previously declared in /nas/wp/www/staging/tasklabels/wp-content/themes/customizr-child-theme/functions.php:61) in /nas/wp/www/staging/tasklabels/wp-content/themes/customizr-child-theme/functions.php on line 100

    (line 100 being the very beginning of the second (copied) code snippet)

    Here is the code I’ve pasted:

    <?php
    
    /*
    *	EMAIL 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' => '{email_URL}', // tag that will be parsed
    		'description' => '<h4 class="tooltip-title">Yikes New | <small>{email_URL}</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' => 'email URL' // 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 == '{email_URL}' ) {
    		return stripslashes( do_shortcode( '[urlparam param="email"]' ) );
    	}
    	// return the tag
    	return $tag;
    }
    
    /*
    *	REFERRED BY 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' => '{referred_by}', // tag that will be parsed
    		'description' => '<h4 class="tooltip-title">Yikes New | <small>{referred_by}</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' => 'Referred by' // 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 == '{referred_by}' ) {
    		return stripslashes( do_shortcode( '[urlparam param="referredby"]' ) );
    	}
    	// return the tag
    	return $tag;
    }

    Edit: Actually I’ll need to pre-populate 3 fields.

    Plugin Author Evan Herman

    (@eherman24)

    Hi MauriceDz,

    If you need to populate additional fields, you just need to add additional items to the appropriate arrays.

    It looks like you duplicated the existing function, which causes an error because you can’t have more than one function named the same thing.

    If you want to add an additional ‘referred_by’ tag to the list, you can add it like so:

    <?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)
    	);
    	/* Add new 'referred by' tag */
    	$available_tags[] = array(
    		'tag' => '{referred_by}', // tag that will be parsed
    		'description' => '<h4 class="tooltip-title">Referred By | <small>{referred_by}</small></h4><hr />' . __( 'Extracts the referred by query parameter and populate the field.' , 'text-domain' ), /// tool tip content that appears on hover
    		'title' => 'Referred By' // 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"]' ) );
    	}
    	// set up a conditional so we parse the '{referred_by} tag
    	if( $tag == '{referred_by}' ) {
    		return stripslashes( do_shortcode( '[urlparam param="ReferredBy"]' ) );
    	}
    	// return the tag
    	return $tag;
    }

    That should add the second, {referred_by} tag to the list.

    Thanks!
    Evan

    Thread Starter Mr Sprezzatura

    (@mauricedz)

    Thanks a lot, that seems to be working perfectly!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Custom default value tags not working’ is closed to new replies.