Hey guys,
How do I grab a new user's user_id after registration? I've tried this but it didn't seem to work:
add_action( 'cred_save_data', 'auto_profile_picture', 10, 2 );
function auto_profile_picture( $new_user_id, $form_data ){
if ( 3263 == $form_data['id'] ) { // 3263 is id of registration form
$user_id = $new_user_id;
-------- rest of code works with $user_id
Thanks,
Rens
Hi Rens,
Thank you for contacting us and I'd be happy to assist.
I've tested the code snippet that you've shared on my test website and it seems to work as expected.
Can you please make sure that the ID "3263" is the correct one for the form that you're testing with?
Note: For step-by-step custom code troubleshooting, you'll find the "WP PHP Console" plugin ( https://wordpress.org/plugins/wp-php-console/ ) very useful, as it makes PHP errors and warnings much simpler to trace.
In case the issue still persists, please share the complete code snippet along with some context around what you are expecting and what is actually happening.
regards,
Waqar
Hi Waqar,
Thanks for the plugin suggestion! Been looking for an easy debugging solution. 🙂
I'll get testing again and let you know how it goes!
Rens
You're very welcome and please let me know how it goes.
For a new question/concern, feel free to start a new ticket.
I've figured out it's not the user id that's the problem. I've started a new ticket here: https://toolset.com/forums/topic/custom-code-doesnt-work-when-using-cred-hook/
My issue is resolved now. Thank you!