MultivendorX Pro
Tagged: after vendor registration hook
-
AuthorPosts
-
-
June 19, 2023 at 5:03 PM #193572matteor182Participant
I have to store some form fields in custom fields created by me, which hook or filter allows me to take all the form data after it has been submitted and registered?
including the id of the newly created user ?
Thank you very much
-
June 20, 2023 at 12:08 PM #193595Sangita Support SquadKeymaster
Hello @matteor182.
Once a vendor registers on the site, his submitted details get already stored in the database.
The details get saved in the user meta table.By the user id you can fetch the user details from the meta table.
If you are looking for something else please explain that so that we can provide you with a hook/filter accordingly. -
June 20, 2023 at 12:48 PM #193611matteor182Participant
Hello,
thanks for the answer,I need exactly the moment after sending the registration form immediately after the new user has been created, because I need the form data and the new user’s id.
thank you very much
-
June 20, 2023 at 5:52 PM #193627Sangita Support SquadKeymaster
You need to fetch the registration form data using this two functions :
$vendor = get_mvx_vendor($user_id);
$first_name = get_user_meta($vendor->id, ‘first_name’, true); -
June 21, 2023 at 1:58 AM #193643matteor182Participant
Hello Sangita,
thanks for the answer,
but when should I use these two functions? Isn’t there a hook that gets called when the user is created after the form is submitted?
if I use the WordPress hook when a generic user is created, I risk calling these functions for non-seller users.
I need a hook where I can hook for example this: do_action(‘mvx_after_register_vendor’, $user_id);
but this only gives me the user_id and instead I need the sent fields of his registration form.
Is there a hook that returns this information to me after the registration form has been submitted and after the user has been created?
thank you very much
-
June 21, 2023 at 2:04 AM #193644matteor182Participant
I found this filter : apply_filters(‘mvx_save_registration_fields’, $mvx_vendor_fields, $customer_id);
I can use it to get the fields , but how can I write values in the custom fields I created without interrupting the seller ‘s registration ?
is it possible from this filter ? can you write me a sample code? Or do I need only a hook?thank you very much
-
June 21, 2023 at 6:35 PM #193673Sangita Support SquadKeymasterThis reply has been marked as private.
-
June 21, 2023 at 8:16 PM #193678matteor182Participant
ok great, I’m just missing one piece of information, how do I recover the data from the submitted form? do I find it stored in the user profile , in the user meta data ?
thanks a lot for the help
-
June 22, 2023 at 11:53 AM #193697Sangita Support SquadKeymaster
@matteor182 The details of the vendor after registration get saved in the user meta table.
You can fetch the user details from the user id. -
June 23, 2023 at 2:03 PM #193760matteor182Participant
i tried with this code,
but it seems that the vendor form data is not yet written in this hook, or rather if i get them from any page the function returns me the registration form data, but from this hook this variable $vendor_application_data is empty.
do you have any idea ?
this is my code, thanks a lot
add_action(‘mvx_after_register_vendor’, ‘tdm_register_agenzia_immobiliare’);
function tdm_register_agenzia_immobiliare($user_id) {
$vendor = get_mvx_vendor($user_id);
$vendor_application_data = get_user_meta(absint($vendor->id), ‘mvx_vendor_fields’, true);
error_log(print_r($vendor_application_data,true));
foreach($vendor_application_data as $question){
if($question[‘label’] == ‘Che tipo di venditore sie ?’ && $question[‘value’] != null){
update_field( ‘vendita_immobiliare’, $question[‘value’], “user_”.$user_id );
}
}
} -
June 23, 2023 at 3:42 PM #193763matteor182Participant
I solved the first problem, taking the data in POST $vendor_application_data = $_POST[‘mvx_vendor_fields’];
this is the correct code, but unfortunately it seems that the custom field is not filled, i tried from another page and the instruction works and fills the custom field, but from the hook it seems not to work, if i look in the DB after the registration, it seems that the custom field is not in the user meta. how can i write in a userm meta from this hook ?
this is the istruction : update_field( ‘vendita_immobiliare’, $question[‘value’], “user_”.$user_id );
and hear my code correctly
add_action(‘mvx_after_register_vendor’, ‘tdm_register_agenzia_immobiliare’);
function tdm_register_agenzia_immobiliare($user_id) {
$vendor = get_mvx_vendor($user_id);
$vendor_application_data = $_POST[‘mvx_vendor_fields’];
foreach($vendor_application_data as $question){
if($question[‘label’] == ‘Che tipo di venditore sie ?’ && $question[‘value’] != null){
update_field( ‘vendita_immobiliare’, $question[‘value’], “user_”.$user_id );
}
}
} -
June 23, 2023 at 4:36 PM #193768matteor182Participant
ok I solved it, the problem was the comfort with the lable, it was always false, I don’t know why, now I compare it with the value and it recognizes it.
thank you very much
-
June 23, 2023 at 6:41 PM #193773Sangita Support SquadKeymaster
Great to hear that. Hope all your issues are solved now.
-
-
AuthorPosts
The topic ‘hoo or filter after vendor registration’ is closed to new replies.