Support

Account

Home Forums ACF PRO Letting users choose their own password on registration

Solved

Letting users choose their own password on registration

  • I am currently using ACF on front-end for user registration with the following code. Everything is good but I need to let users choose their own password when they register. Please let me know how I can achieve that.

    <form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
    	<input type="text" name="user_login" value="" placeholder="Username" id="user_login" class="input" />
    	<input type="text" name="user_email" value="" placeholder="Email" id="user_email" class="input"  />
    	<?php do_action('register_form'); ?>
    	<input type="submit" value="Register" id="register" />
    </form>
  • Hi @futaba

    I’m afraid I don’t see ACF involved in the code you’ve shared. If you want to create a registration form, please check this tutorial: https://code.tutsplus.com/tutorials/creating-a-custom-wordpress-registration-form-plugin–cms-20968. Because this is more related to WordPress instead of ACF, kindly visit WordPress community for further support.

    I hope this helps πŸ™‚

  • Hello James,

    Thanks for you reply. I did look into the link before but later found the code I am using to be easier. I have created custom fields for the user forms.

    User Forms

    This way, the custom fields are automatically added to the registration form & user profile. As I am using ACF this way (easier too), I may need to do the tweak based on this.

    Regards

  • Hi @futaba

    Unfortunately, the method you were using (pointing to wp-login.php?action=register) won’t allow you to have a password field. As a workaround, you can add a password field manually like this:

    <input type="password" name="user_password" value="" placeholder="Password" id="user_password" class="input" />

    And then use the user_register action and wp_set_password() function to change the password like this:

    add_action( 'user_register', 'myplugin_registration_change_pass', 10, 99 );
    
    function myplugin_registration_change_pass( $user_id ) {
    
        if ( isset( $_POST['user_password'] ) )
            wp_set_password( $_POST['user_password'], $user_id );
    
    }

    Like I said before, this topic is more related to WordPress. For further support, kindly visit WordPress community instead.

    I hope this helps πŸ™‚

  • Thank you! Much appreciated πŸ™‚

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.