• Resolved fabriciocarraro

    (@fabriciocarraro)


    Hi guys,

    I managed to hide the “Username”, “Confirm Password” and “Confirm email” fields (it’s a Free Membership level). However, the Default order of the fields for the user to fill in that PMP gives me is the “Password” first and “Email” underneath, which doesn’t make much sense.

    Would it be possible to change this and have the “Email” field on top?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi @fabriciocarraro

    This would require a small custom code snippet to move the div’s around. Here is a personal gist I’ve written for one of my own sites – https://gist.github.com/andrewlimaza/a29f28d2a4df9937d966801679d3b021

    You may add this to your site via a custom plugin or using a plugin like Code Snippets.

    I hope this helps get you started.

    Thread Starter fabriciocarraro

    (@fabriciocarraro)

    Fantastic! Thank you very much!

    cosmiclove1978

    (@cosmiclove1978)

    @fabriciocarraro Hello there,

    Mind telling us how you managed to hide “username” field? I’ve spent hours looking for a solution (via css) but because the field is required, the form won’t validate.

    Does your form validate after remove the “username” field and if so, how did you manage to do it?

    I’ll appreciate any tip you might have for me. Thanks in advance.

    Thread Starter fabriciocarraro

    (@fabriciocarraro)

    @cosmiclove1978 Actually, on top on hiding it via CSS, you have to add some code (I used the Code Snippets plugin) so that it copies the email to be the username as well. I also hid the “Confirm email” and “Confirm password” fields, so this code below also copies both of them as well from the regular “email” and “password” fields. Here’s the code:

    function my_generate_fields_for_users() {
    
    	if ( !isset( $_REQUEST['level'] ) ) {
    		return;
    	}
    
    	$generate_data_levels = array( '1'); // Level ID's to generate data for.
    
    	if ( ! in_array( $_REQUEST['level'], $generate_data_levels ) ) {
    		return;
    	}
    
    	// Generate Email Address as username.
    	if(!empty($_REQUEST['bemail'])) {
        		$_REQUEST['username'] = $_REQUEST['bemail'];
        	}
        
      	if(!empty($_POST['bemail'])) {
        		$_POST['username'] = $_POST['bemail'];
    	}
        
      	if(!empty($_GET['bemail'])) {
       		 $_GET['username'] = $_GET['bemail'];
    	}
    	
    	//Copy email to Confirm Email	
    	if( !empty( $_REQUEST['bemail'] ) ) {
    		$_REQUEST['bconfirmemail'] = $_REQUEST['bemail'];
    	}
    	
    	// Generate passwords confirm.
    	if( !empty( $_REQUEST['password'] ) ) {
    		$_REQUEST['password2'] = $_REQUEST['password'];
    	}
    }
    add_action( 'init', 'my_generate_fields_for_users' );
    cosmiclove1978

    (@cosmiclove1978)

    @fabriciocarraro There are no words to express how grateful I am to you, Fabricio. The suggested solution was spot on! My checkout forms can validate now and no username field needed (hidden now). Muito obrigado!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Customize checkout – Password x Email’ is closed to new replies.