Jump to content


Photo

Adding custom fields error


  • Please log in to reply
No replies to this topic

#1 alexpaul

alexpaul

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 07 August 2019 - 05:11 AM

Can anyone tell me how to add custom fields on the registration page as I am having an error in the code

function wooc_validate_extra_register_fields( $username, $email, $validation_errors ) {
      if ( isset( $_POST['billing_first_name'] ) && empty( $_POST['billing_first_name'] ) ) {
             $validation_errors->add( 'billing_first_name_error', __( '<strong>Error</strong>: First name is required!', 'woocommerce' ) );
      }
      if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) {
             $validation_errors->add( 'billing_last_name_error', __( '<strong>Error</strong>: Last name is required!.', 'woocommerce' ) );
      }
         return $validation_errors;
}
add_action( 'woocommerce_register_post', 'wooc_validate_extra_register_fields', 10, 3 );

The reference tutorial I have see WooCommerce form and implemented all the steps following this tutorial 

 



looking for the best presta addons with outstanding support? check this: PrestaShop Modules