• Resolved tpo

    (@topod)


    Hi!

    I couldn’t find a hook in the documentation that handles saving data in the user profile. Is something like this available in your plugin?

    I would need to verify via a hook whether the old and new information about the customer’s last name is the same, or whether it has been changed, and send an e-mail via a condition.

    For me, a link to a hook that handles data storage is enough. The built-in hook in WooCommerce “email_change_email” does not work for me in the Checkout Form.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    You can achieve your requirement using woocommerce_checkout_process hook.

    Please refer to the below example code for more details.

    add_action('woocommerce_checkout_process', 'th_check_change_checkout_value');
    function th_check_change_checkout_value(){
        $last_name = isset($_POST['billing_last_name']) ? $_POST['billing_last_name'] : '';
        $user_id = get_current_user_id();
        $old_last_name = isset($user_id) ? get_user_meta($user_id, 'billing_last_name', true) : '';
        if($last_name != $old_last_name){
            // your action here
        }
    }

    Thank you!

    Thread Starter tpo

    (@topod)

    Thanks, the code snippet works only at checkout.

    Is there a hook that handles save data in profile fields in the profile (My Account section) and I can check the old and new surname through it?

    Many thanks!

    • This reply was modified 2 years, 1 month ago by tpo.
    • This reply was modified 2 years, 1 month ago by tpo.
    Plugin Author ThemeHigh

    (@themehigh)

    Please refer to the below example code for more details.

    function th_my_profile_update( $user_id ) {
        $last_name = get_user_meta($user_id, 'billing_last_name', true);
        $last_name = isset($_POST['billing_last_name']) ? $_POST['billing_last_name'] : '';
        $old_last_name = isset($user_id) ? get_user_meta($user_id, 'billing_last_name', true) : '';
        if($last_name != $old_last_name){
            // your action here
        }
    }
    add_action( 'profile_update', 'th_my_profile_update' );

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘E-mail if any field is changed during saving’ is closed to new replies.