My Courses > CustomizeWoo > Module 6 > Lesson 07: Add Last Name @ My Account Registration

Add Last Name @ My Account Registration

MARK LESSON AS COMPLETE

You can use this exercise as a test. Stop the video after the project description and see if you can manage to find the PHP solution. Then continue watching the video to watch me code the task.

Video

Please note: English captions are enabled by default (click on “CC” in the video player to disable). Also, you can click on the “gear” icon to manage quality and playback speed. Enjoy!

Sorry, this video is only visible to logged in Business Bloomer Club members with a PRO PASS.
If you joined already, please log in.
Otherwise, here is why you should join the Club.

2 thoughts on “Add Last Name @ My Account Registration

  1. Why would you only save the last name to billing last name? Shouldn’t it be added to the native last name field as well?

    Here is how to have the new “lastname” field be saved in both places…

    add_action( 'woocommerce_created_customer', 'bbloomer_save_name_fields' );
    function bbloomer_save_name_fields( $customer_id ) {   
        if ( isset( $_POST['lastname'] ) ) {
            update_user_meta( $customer_id, 'billing_last_name', sanitize_text_field( $_POST['lastname'] ) );
            update_user_meta( $customer_id, 'last_name', sanitize_text_field($_POST['lastname']) );
        }
    }
    
    1. Yes, you’re correct!

Questions? Feedback? Support? Leave your comment now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]

Your email address will not be published. Required fields are marked *