• Hello!

    Mailchimp Add On is not updating on profile save when a user change their profile.
    – (I had select “YES” for “update on profile save” on the add on settings page)-
    – Merge Tags are already created on Mailchimp.

    Im using Custom Fields, but the addon is not updating fields like LNAME, neither.
    ——–
    Here is my recipe for the Custom Fields:

    function mytheme_add_fields_to_signup(){
    	//don't break if Register Helper is not loaded
    	if(!function_exists( 'pmprorh_add_registration_field' )) {
    		return false;
    	}
    	
    	$fields = array();
    
    

    $fields[] = new PMProRH_Field(
    ‘GENERO’, // input name, will also be used as meta key
    ‘radio’, // type of field
    array(
    ‘options’ =>
    array(
    ‘HOMBRE’ => ‘Hombre’,
    ‘MUJER’ => ‘Mujer’,
    ),

    ‘label’=>’Soy:’, // custom class
    ‘profile’=>true, // show in user profile
    ‘required’=>true, // make this field required
    ‘location’ => ‘after_submit_button’,
    )
    );
    //add the fields to default forms
    foreach($fields as $field){
    pmprorh_add_registration_field(
    ‘after_email’, // location on checkout page
    $field // PMProRH_Field object
    );
    }
    }
    add_action( ‘init’, ‘mytheme_add_fields_to_signup’ );


    ——————-

    My recipe for Mailchimp:

    
    

    function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user )

    {

    $new_fields = array(

    “GENERO” => $user->GENERO,

    );

    $fields = array_merge( $fields, $new_fields );

    return $fields;
    }

    add_action( ‘pmpro_mailchimp_listsubscribe_fields’, ‘my_pmpro_mailchimp_listsubscribe_fields’, 10, 2 );

    /**
    * Tell PMPro MailChimp to always synchronize user profile updates. By default it only synchronizes if the user’s email has changed (optional).
    * Requires PMPro Mailchimp v2.0.3 or higher.
    */
    add_filter( ‘pmpromc_profile_update’, ‘__return_true’ );

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter saraelba

    (@saraelba)

    Forgot to say:

    This custom field (GENERO) is added on mailchimp FOR NEW USERS.
    Im having troubles ONLY when a user UPDATE THEIR PROFILE.
    (the profile is update ONLY on the WP site. But not in mailchimp)

    Also I forgot to say: THANKS for your help ??

    Thread Starter saraelba

    (@saraelba)

    Testing the AddOn, I see isn’t adding new members!!!
    AND only updates the members emails. ??

    I had updated the AddOn trying to fix this issue. But nothing happened.

    Plugin Author David Parker

    (@dlparker1005)

    Hello @saraelba, thank you for using Paid Memberships Pro!

    The PMPro Mailchimp v2.3.2 update released last week now includes a “Log API Calls?” setting on the PMPro Mailchimp settings page. When set to “Yes”, PMPro Mailchimp will log all the information PMProMC tries to set to Mailchimp and the resulting response that PMProMC receives from Mailchimp.

    Can you please enable that setting, check out as a new user on your site, and let me know if there is any error that then shows up from Mailchimp in the PMPro MC log file? That file can be found at /wp-content/plugins/pmpro-mailchimp/logs/ on your file server.

    If there is no error being shown there, can you please also let me know if there are any errors being shown in your PHP error log?

    • This reply was modified 3 years, 7 months ago by David Parker.
    Thread Starter saraelba

    (@saraelba)

    Hello David!

    Thanks for your reply…
    After several tests, I had found the “bug”:
    The bug is in the “State dropdown” plugin.

    This plugin use $bstate and $country.

    So, merge tags for mailchimp must be in lowercase too, I guess (?)
    The problem is when I write my merge tags in lowercase on mailchimp site, it becomes UPPERCASE after save.

    Here is the code I use for “Country and State” custom fields + Mailchimp function:

    function add_billing_fields_to_profile()
    {
    	
    	global $bcountry;
    	global $bstate;
    	
    	//check for register helper
    	if(!function_exists("pmprorh_add_registration_field"))
    		return;
    	
    	//define the fields
    	
    	
    	$fields = array();
    	$fields[] = new PMProRH_Field(
    		"bcountry", 
    		"select", 
    		array('label'=>'Country:', 
    			"options"=>array
    			(
    			$bcountry
    			),
    			"profile"=>true, "required"=>true,
    		)
    	);
    	$fields[] = new PMProRH_Field(
    		"bstate", 
    		"select", 
    		array('label'=>'State:', 
    			"options"=>array
    			(
    			$bstate
    			),
    			"profile"=>true, "required"=>true,
    		)
    	);
    
    function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) 
    
    {
    	$new_fields =  array(
    		
    		
    		"bcountry" => $user->BCOUNTRY,
    		"bstate" => $user->BSTATE,
    		/*AND MORE CUSTOMS FIELD HERE created by me, that works fine. No bugs.*/
    		
    		);
    
    	$fields = array_merge( $fields, $new_fields );
    	  
    	return $fields;
    }
    
    add_action( 'pmpro_mailchimp_listsubscribe_fields', 'my_pmpro_mailchimp_listsubscribe_fields', 10, 2 );
    
    /**
     * Tell PMPro MailChimp to always synchronize user profile updates. By default it only synchronizes if the user's email has changed (optional).
     * Requires PMPro Mailchimp v2.0.3 or higher.
     */
    add_filter( 'pmpromc_profile_update', '__return_true' );

    I had change the
    “bcountry” => $user->BCOUNTRY,
    “bstate” => $user->BSTATE,

    to

    “BCOUNTRY” => $user->BCOUNTRY,
    “BSTATE” => $user->BSTATE,

    to

    “bcountry” => $user->bcontry,
    “bstate” => $user->bstate,

    etc…

    But No results ??

    • This reply was modified 3 years, 7 months ago by saraelba.
    • This reply was modified 3 years, 7 months ago by saraelba.
    Plugin Author David Parker

    (@dlparker1005)

    Hi @saraelba,

    So, merge tags for mailchimp must be in lowercase too, I guess (?)
    The problem is when I write my merge tags in lowercase on mailchimp site, it becomes UPPERCASE after save.

    You are correct that merge tags in Mailchimp should be uppercase, though this should not change how that information is stored in PMPro. In your associative array, each key should be the name of the merge field in Mailchimp (uppercase) and the value should be the value stored in PMPro (case may vary).

    As the fields that you are looking to send are $user->bcontry and $user->bstate, can you please try the following setup:

    "BCOUNTRY" => $user->bcountry,
    "BSTATE" => $user->bstate,
    

    As this topic is specific to modifying custom code on your particular site, if you would like more guidance or hands on help implementing or debugging this custom behavior, please sign up at https://www.paidmembershipspro.com/pricing and our support team will be able to walk you through this process there.

    Thread Starter saraelba

    (@saraelba)

    Hi David,Thanks for your help.

    I had try with the

    "BCOUNTRY" => $user->bcountry,
    "BSTATE" => $user->bstate,

    you recommended me and then add a new user through the checkout page:

    Results:

    the user is added but the Mailchimp addOn IS NOT adding/synchronizing the following fields:

    $baddress1
    $bcountry
    $bstate
    $bzipcode

    The Mailchimp AddOn it’s only synchronizing the following fields (even when a user update their profile):

    $bfirstname (merge field set as FNAME in mailchimp)
    $blastname (merge field set as LNAME in mailchimp)
    $bemail (merge field set as EMAIL or MERGE0 in mailchimp)

    (and of course, other custom fields I had created)

    Here is the recipe I use for the Mailchimp AddOn:

    function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) 
    
    {
    	$new_fields =  array(
    		
    		"BADDRESS1" => $user->baddress1,
    		"BZIPCODE" => $user->bzipcode,
    		"BCOUNTRY" => $user->bcountry,
    		"BSTATE" => $user->bstate,
    		
    		);
    	$fields = array_merge( $fields, $new_fields );
    	  
    	return $fields;
    }
    
    add_action( 'pmpro_mailchimp_listsubscribe_fields', 'my_pmpro_mailchimp_listsubscribe_fields', 10, 2 );
    
    /**
     * Tell PMPro MailChimp to always synchronize user profile updates. By default it only synchronizes if the user's email has changed (optional).
     * Requires PMPro Mailchimp v2.0.3 or higher.
     */
    add_filter( 'pmpromc_profile_update', '__return_true' );


    I REALLY appreciate your help!!! Have a nice day!!!

    • This reply was modified 3 years, 7 months ago by saraelba.
    • This reply was modified 3 years, 7 months ago by saraelba.
    Plugin Author David Parker

    (@dlparker1005)

    Hello,

    In order to look further into this issue, we would need to see your PMPro Mailchimp debug log file and see how your site is set up. If you would like additional help debugging this custom functionality, please sign up at https://www.paidmembershipspro.com/pricing and our support team will be able to walk you through this process there.

    Thread Starter saraelba

    (@saraelba)

    Hi David,

    I had trying diffrent combinations of code and see the log file.

    #1
    CODE:

    function add_billing_fields_to_profile()
    {
    	
    	global $bcountry;
    	global $bstate;
    	
    	//check for register helper
    	if(!function_exists("pmprorh_add_registration_field"))
    		return;
    	
    	//define the fields
    function add_billing_fields_to_profile()
            $fields = array();
    	$fields[] = new PMProRH_Field(
    		"bcountry", 
    		"select", 
    		array('label'=>'Pais:', 
    			"options"=>array
    			(
    			$bcountry
    			),
    			"profile"=>true,
    		)
    	); 
    // and same code for $bstate here
    
    function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) 
    
    {
    	$new_fields =  array(
    		
           "BCOUNTRY" => $user->BCOUNTRY,
           "BSTATE" => $user->BSTATE,
    ); 

    LOG RESULTS:

    Logged On: 03/18/2021 17:36:23
    Processing update for audience AUDIENCE namehere (b12d1146f5): Array
    (
    [0] => stdClass Object
    (
    [email_address] => xxxxxxxx
    [status] => subscribed
    [merge_fields] => Array
    (
    [FNAME] => Arde
    [LNAME] => Ardministrador
    [BADDRESS1] =>
    [BZIPCODE] =>
    [BCOUNTRY] =>
    [BSTATE] =>
    [PMPLEVELID] => 1
    [PMPALLIDS] => {1}
    [PMPLEVEL] => Cuota de socio anual
    )

    )

    )

    ————-
    Logged On: 03/18/2021 17:36:25
    Mailchimp Response: No errors detected.
    ————-

    ********************

    #2
    CODE:

    SAME code before except for:

    function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) 
    
    {
    	$new_fields =  array(
    		
           "BCOUNTRY" => $user->bcountry,
           "BSTATE" => $user->bstate,
    ); 

    LOG RESULTS:

    Logged On: 03/18/2021 17:20:56
    Mailchimp Response: 1 error(s). Array
    (
    [0] => stdClass Object
    (
    [email_address] => [email protected]
    [error] => Your merge fields were invalid.
    [error_code] => ERROR_GENERIC
    )

    )

    ————-
    ***************************
    #3
    CODE:

    Same code except for:

    "bcountry" => $user->BCOUNTRY,
     "bstate" => $user->BSTATE,

    LOG RESULTS:

    Logged On: 03/18/2021 17:57:52
    Processing update for audience LIST audience (b12d1146f5): Array
    (
    [0] => stdClass Object
    (
    [email_address] => xxxxxxxxxx
    [status] => subscribed
    [merge_fields] => Array
    (
    [FNAME] => Arde
    [LNAME] => Ardministrador
    [BADDRESS1] =>
    [BZIPCODE] =>
    [bcountry] =>
    [bstate] =>
    [PMPLEVELID] => 1
    [PMPALLIDS] => {1}
    [PMPLEVEL] => Cuota de socio anual
    )

    )

    )

    ————-
    Logged On: 03/18/2021 17:57:53
    Mailchimp Response: No errors detected.
    ————-`

    ************************
    ABOUT THE PROFILE UPDATE PAGE:
    When I change the country and/or state, the page shows the “profile update” message. But when I refresh the page the changes are not saved. (same from WP admin).

    Any clue?

    In order to look further into this issue, we would need to see how your site is set up

    What kind of information you would need?

    THANKS A LOT!!! ??

    • This reply was modified 3 years, 7 months ago by saraelba.
    Thread Starter saraelba

    (@saraelba)

    Ok…

    I feel stupid ??

    The issue was in Mailchimp:

    The Merge Tag for country and state was set as an ADRESS field…

    But, this fields must be set as a TEXT field to work properly.

    At the end the code is

    "BCOUNTRY" => $user->bcountry,
    "BSTATE" => $user->bstate,

    I think I found the solution.
    I’ll add a NEW MEMBER tomorrow and let you know.

    +++++++++++

    Anyway, IM HAVING THIS ISSUE with the profile edit page:

    1) At Edit member profile’s page (or WP-admin’s edit member profile) I change the country and state.
    2) Click on save button
    3) I see the “Profile updated” message and changes made on the page.
    …and then:
    4) Refresh the page.
    5) Changes not saved. ??

    Im searching in GitHub and wordpress support forum about this issue but I cannot see anything.
    Just this, but this is a STATE issue only:
    https://github.com/strangerstudios/pmpro-state-dropdowns/pull/13

    Maybe I must open a new topic i a proper forum?
    THANKS!!!

    • This reply was modified 3 years, 7 months ago by saraelba.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Not synchronize when a member update their profile’ is closed to new replies.