• bt_dev

    (@biotrace)


    Hi – Is it possible to have the address information supplied in a registration form populate the woocommerce user address fields?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ultimate Member

    (@ultimatemember)

    Hi,

    This is not possible at the moment but will add to user suggestion list.

    Thanks

    Thread Starter bt_dev

    (@biotrace)

    Hi there – After posting this I found an entry on your forums that helped to enable the address info to be collected for woocommerce. It does require the functions.php to be edited however. Details below (thanks to sandra frank for the contribution) – https://ultimatemember.com/forums/topic/woocommerce-integration/

    Here’s my full code in case anyone else needs it! Thanks all.

    Note 1: Be aware that the field names (for example: um_user (‘field_name’)) are the ones I put in for my use. You may have different ones.

    Note 2: The billing and shipping field names are correct for woocommerce.
    (Here’s the full list: )

    Note 3: I used the action hook ‘um_post_registration_save’ but UM suggested ‘um_after_user_is_approved’ in the above replies. Mine worked so I didn’t change it.

    This code was added to functions.php file in my child theme folder.

    add_action ('um_post_registration_save', 'custom_update_profile',99);
    function custom_update_profile ($user_id) {
    	/*$user_id = um_profile_id();*/
    	global $ultimatemember;
    	um_fetch_user( $user_id );
    	
    	$profilefirstname = um_user( 'first_name' );
    	update_user_meta( $user_id, 'billing_first_name', $profilefirstname );
    	update_user_meta( $user_id, 'shipping_first_name', $profilefirstname );
    	
    	$profilelastname = um_user( 'last_name' );
    	update_user_meta( $user_id, 'billing_last_name', $profilelastname );
    	update_user_meta( $user_id, 'shipping_last_name', $profilelastname );
    
    	$profilecompany = um_user( 'business_name' );
    	update_user_meta( $user_id, 'billing_company', $profilecompany );
    	update_user_meta( $user_id, 'shipping_company', $profilecompany );
    
    	$profileaddress1= um_user( 'street_address_1' );
    	update_user_meta( $user_id, 'billing_address_1', $profileaddress1 );
    	update_user_meta( $user_id, 'shipping_address_1', $profileaddress1 );
    	
    	$address2= um_user( 'street_address_2' );
    	update_user_meta( $user_id, 'billing_address_2', $address2 );
    	update_user_meta( $user_id, 'shipping_address_2', $address2 );
    
    	$profilecity= um_user( 'city' );
    	update_user_meta( $user_id, 'billing_city', $profilecity);
    	update_user_meta( $user_id, 'shipping_city', $profilecity);
    
    	$profilestate= um_user( 'state' );
    	update_user_meta( $user_id, 'billing_state', $profilestate);
    	update_user_meta( $user_id, 'shipping_state', $profilestate);
    	
    	$profilezip_code= um_user( 'zip_code' );
    	update_user_meta( $user_id, 'billing_postcode', $profilezip_code);
    	update_user_meta( $user_id, 'shipping_postcode', $profilezip_code);
    
    	$profilecountry= um_user( 'country' );
    	update_user_meta( $user_id, 'billing_country', $profilecountry);
    	update_user_meta( $user_id, 'shipping_country', $profilecountry);
    	
    	$profileemail= um_user( 'user_email' );
    	update_user_meta( $user_id, 'billing_email', $profileemail);
    	
    	$profilephone= um_user( 'phone_number' );
    	update_user_meta( $user_id, 'billing_phone', $profilephone);
    	
    	return $user_id;
    	}
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Address information collected by registration form’ is closed to new replies.