Register Hook seems to be not working as expected (at least in my case)
-
Hey there,
I tried to have the username as optional for my end users. To do so, I’ve hide the username field on the frontend.
On my child theme functions.php file, I’ve added the wpmem_pre_register_data hook to generate a random username.
I’ve logged the output using print_r(), username looks good (something like user_qsdfmlkjm) in the hook.add_filter( 'wpmem_pre_register_data', 'custom_set_username_field' ); function custom_set_username_field( $fields ) { $random_username = 'user_' . wp_generate_password(8, false); $fields['username'] = $random_username; echo "<pre>"; print_r( $fields ); echo "</pre>"; return $fields; }
But when the user is save in the database, the username remains the one the user typed in the register form.
Did I do something wrong? I’ve carefully read the documentation (really well done btw), from my understanding, this is the correct hook to use.
Could you please give me some help?
Thank you!
- The topic ‘Register Hook seems to be not working as expected (at least in my case)’ is closed to new replies.