August 18, 2015 at 9:12 pm 67865 |
Nayem | Hi,
I added a few extra fields to my registration form and have everything saving correctly, but for some reason it forces me to save my fields twice. The first time is while registering, and the second time is while being on the sellers dashboard settings page.
Here's the function that creates a new seller.
function custom_create_seller( $user_id, $data ) {
if ( $data['role'] != 'seller' ) {
return;
}
// Get data from my-account register form and update dokan-settings
$data['address']['street_1'] = sanitize_text_field( $_POST['street_1'] );
$data['address']['street_2'] = sanitize_text_field( $_POST['street_2'] );
$data['address']['city'] = sanitize_text_field( $_POST['city'] );
$data['address']['zip'] = sanitize_text_field( $_POST['zip'] );
$data['address']['country'] = sanitize_text_field( $_POST['country'] );
$data['address']['statess'] = sanitize_text_field( $_POST['state'] );
$dokan_settings = array(
'store_name' => strip_tags( $_POST['shopname'] ),
'social' => array(),
'address' => $data['address'],
'payment' => $email['payment'],
'phone' => $_POST['phone'],
'show_email' => 'no',
'location' => '',
'find_address' => '',
'dokan_category' => '',
'banner' => 0,
);
update_user_meta( $user_id, 'dokan_profile_settings', $dokan_settings );
Dokan_Email::init()->new_seller_registered_mail( $user_id );
}
add_action( 'woocommerce_created_customer', 'custom_create_seller', 10, 2);
I found this action on the template-settings.php page, but it did not work when adding it this function: do_action( 'dokan_store_profile_saved', $store_id, $dokan_settings );
Could you let me know what I'm doing wrong.
Thanks!
|
August 19, 2015 at 11:20 am 67967 |