Skip to:

Woocommerce First and Last Names?

  • I know I’m missing something easy here but cannot find it…

    People only join my site through a Woocommerce order. Once they are joined they can request to join Private groups in BuddyPress. It looks like when someone signs up the billing_first_name and billing_last_name from Woo copy to the “Name” field in WP, but only the billing_first_name goes to the “Name” field in the BuddyPress Extended Profile.

    How can I get the BP Extended Profile name to use first and last name and match WP and Woo?


Viewing 1 replies (of 1 total)
  • I’ve found WooCommerce is setting the display name to just the first name. It appears BP uses the display name which makes sense for BP. To change this, you can use this bit of code:

    function g3_change_display_name($name) {
    	if ( isset( $_POST['billing_first_name'] ) ) $firstname = sanitize_text_field( $_POST['billing_first_name'] );
    	if ( isset( $_POST['billing_last_name'] ) ) $lastname = sanitize_text_field( $_POST['billing_last_name'] );
    	if ($firstname && $lastname) $name = $firstname . ' ' . $lastname;
    	return $name;

    It uses a WP hook so should be good no matter what plugins you have or don’t and follows the logic from if curious. Without Woo of course, the billing_first_name and billing_last_name would be different.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar