BuddyDev

Search

[Resolved] Can I remove the email address (required) from reg (I have autologin plugin)

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #13605

    Hi,
    Welcome to BuddyDev forums.

    Even though the auto activation is enabled, WordPress users must have an email address associated with their account. WordPress will not allow user registration if the email address is not specified.

    In other words, It is possible to overcome this by specifying an email on invalid domain but you can not remove the requirement completely.

    Please do note that specifying the invalid email will make accounts inaccessible and difficult to identify when they forget password.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    salsathe4th on #13606

    Thank you for the reply!

    Is there a way to have the email section automatically filled out with a random email? I don’t want people to put in personal ones.

    I will have note about visitors writing down their username and password

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #13629

    Hi,
    You can put the following code in your theme’s functions.php or in the wp-content/plugins/bp-custom.php

    
    /**
     * Update BuddyPress signup email to an invalid address
     */
    function buddydev_update_bp_signup_email() {
    	// we use the username to create emails, It is needed.
    	if ( empty( $_POST['signup_username'] ) ) {
    		return;
    	}
    
    	$temp_email = $_POST['signup_username'] . random_int( 1, 1000 ) . '@example.com';
    
    	$_POST['signup_email'] = $temp_email;
    }
    
    add_action( 'bp_signup_pre_validate', 'buddydev_update_bp_signup_email' );
    
    

    That removes the email from requirement.

    You will need to hide email field though.

    Here is css

    
    label[for="signup_email"], 
    #signup_email{
    	display:none !important;
    }
    
    

    You can use the css or simply remove the fields form register.php

    Hope this helps.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    salsathe4th on #13659

    I am getting the error:

    Your PHP code changes were rolled back due to an error on line 608 of file wp-content/themes/twentyseventeen/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘&’, expecting ‘]’

    It’s talking about line ” if ( empty( $_POST['signup_username'] ) ) {“

    • This reply was modified 6 years, 1 month ago by salsathe4th.
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #13662

    Please make sure that you copy the code from the topic here and not from the mail.

    The code sent on email notification is entity encoded and will cause issue.

    Please check if copying from here works or not?

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    salsathe4th on #13664

    WORKED PERFECTLY!

    Thank you 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #13665

    You are welcome 🙂

The topic ‘ [Resolved] Can I remove the email address (required) from reg (I have autologin plugin)’ is closed to new replies.

This topic is: resolved