Updating WordPress user meta data after login
If you require to update some user meta data after the user logged in to your WordPress site you can use one of the below codes.
Method 1 (recommended)
This method requires Super Forms v6.3.709 or higher to work
The preferred method would be to use the build in Super Forms hook, using the code below. Simply replace push_id
with your form field name and custom_user_meta_data_key
with the user meta data key that you would like to update.
Method 2
This method also works for any Super Forms version
The second option is to use a WordPress core hook. In this example you will have to do a couple of more steps in order to get the desired result. And you have to take not that this will not be executed if the user tries to login while they where already logged in. That's why it's recommended to use the build in Super Forms hook instead. When using the below code, make sure to replace both the my_form_field_name
and my_custom_user_meta_key
in the code below accordingly so that they match your form field name and the meta key that requires updating.
Last updated