-
Hi,
I am using your plugin with mostly the Woocommerce fields as fields for registration (such as billing_first_name, billing_last_name) etc. This words perfectly fine. However, in the WordPress admin panel, when I click on the tab Users, I don’t see the names of the registered users. This is (ofcourse) because wordpress uses different meta-fields for (for example) the first name and last name.
My question is thus, is it possible to “synchronize” some of the WooCommerce fields with other fields, on the moment that the registration is succesful? So, for example, when a person is registering and fills in the form. Then clicks on submit. After all the fields are validated succesfully validated, the value of billing_first_name is also put in first_name and then saved. Is this possible? Maybe with a hook?
I am using wordpress 3.7.
plugin version 1.0.55Hi there, please mind validating your purchase code? I’ll try to give you instructions asap. 🙂 Thanks alot!
Ah, I forgot.
I updated my profile with my purchase code.
Thanks in advance! I hope to hear from you soon.
Hi,
I was wondering if you can give me the instructions.
Thanks in advance.
You can use the hook that runs after profile is updated with UserPro.
Example
PHP1234567add_action('userpro_profile_update', 'userpro_change_data', 10, 2);function userpro_change_data($form, $user_id){global $userpro;if (isset($form['billing_first_name'])){update_user_meta($user_id, 'first_name', $form['billing_first_name']);}}Hooks can do awesome things when you get the hang of it. 🙂
This hook is available in functions/user-functions.php for more details. It passes the SUBMITTED FORM and User ID, so basically you can use it to sync any field.. or for example update specific field From another field in the form.
A similar hook that does PRE FORM UPDATE is available too. Maybe if you want to block usage of specific username, display name (………….so on)
do_action(‘userpro_pre_profile_update’, $form, $user_id);
🙂 Hope that answer helps! These hooks are awesome, I’ll make sure they’re in the docs in the near future
Dear Ahmed, could you please give me some instruction about that how should I use it 🙂
I have been working one day but could not figure out…
I put this hook all function files but still getting error…Thanks in advance…
I have learned Function References and solved the puzzle 🙂
Put below code very end of the userpro/functions/user-functions.php file(If you see “� 39;” in the code; you should put Apostrophe instead of it …)
PHP12345678910111213function userpro_change_data($form, $user_id){global $userpro;if (isset($form['billing_first_name'])){update_user_meta($user_id, 'first_name', $form['billing_first_name']);}if (isset($form['billing_last_name'])){update_user_meta($user_id, 'last_name', $form['billing_last_name']);}}add_action('userpro_profile_update', 'userpro_change_data', 10, 2);add_action('userpro_profile_update', 'userpro_change_data', 20, 2);Update;
PHP123456789101112131415function userpro_change_data($form, $user_id){global $userpro;if (isset($form['billing_first_name'])){update_user_meta($user_id, 'first_name', $form['billing_first_name']);}if (isset($form['billing_last_name'])){update_user_meta($user_id, 'last_name', $form['billing_last_name']);}if (isset($form['billing_country'])){update_user_meta($user_id, 'country', $form['billing_country']);}}add_action('userpro_profile_update', 'userpro_change_data', 10, 2);add_action('userpro_profile_update', 'userpro_change_data', 20, 2);add_action('userpro_profile_update', 'userpro_change_data', 30, 2);
You must be logged in to reply to this topic.