• Resolved 1wdtv

    (@1wdtv)


    Love the plugin!

    Using it as a way to allow subscribers to update their Mailchimp group subscriptions from an embedded form (in the WooCommerce my-account dashboard).

    Is there a way to use an already registered user’s EMAIL field as the value for the Email placeholder/value options …thus avoiding the need for them to type out their email (and possibly using a different email than that which they used to originally sign-up).

    Thank you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter 1wdtv

    (@1wdtv)

    Update:
    I worked out how to edit the original admin function…but your documentation on how to create additional merge tags (by way of the filter) is missing a fully working php example.

    Would you be so kind as to show me with the following how to turn that into a fully functional “apply filter” snippet that I can add to functions.php so as to make the email merge tag available (now that I know it works if I edit the original function)?

    Thanks!
    spence

    			// user email.
    			if ( $default_tag == '{email}' ) {
    				global $user_email;
    			    get_currentuserinfo();
    				$default_tag = $user_email;
    			}
    
    • This reply was modified 5 years, 11 months ago by 1wdtv.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Spence,

    Glad you’re enjoying the plugin! You can definitely extend it in the way you describe.

    I think there’s an easier solution than trying to make a custom MERGE field. You’re using our shortcode in the WooCommerce account page, right? What’s the ID of the form?

    If the user is logged in, this snippet will default their email for form ID 2.

    // Populate email field for logged-in users.
    add_filter( 'yikes-mailchimp-EMAIL-default-value', 'yikes_mailchimp_default_email_address_for_logged_in_users', 10, 3 );
    
    function yikes_mailchimp_default_email_address_for_logged_in_users( $default_value, $field, $form_id ) {
    	if ( (int) $form_id === 2 && is_user_logged_in() ) {
    		$user = wp_get_current_user();
    		return $user->user_email;
    	}
    
    	return $default_value;
    }

    Let me know if that works for you.

    Cheers,
    Kevin.

    Thread Starter 1wdtv

    (@1wdtv)

    Brilliant!
    This is perfect Kevin, thank you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Possible for logged-in user email to be placeholder value?’ is closed to new replies.