Viewing 3 replies - 1 through 3 (of 3 total)
  • You can easily do it using JavaScript. Just hide the text box on page load, attach an ‘onclick’ handler to the submit button. Inside it grab the value of the ‘e-mail’ field and put it into the ‘username’ field. That way username will always be the same as e-mail in the DB. Not sure how you’d handle validation messages though, as they will not always be making sense after you’ve made your modification.

    I recommend jQuery library, as it can be easily included in the page (if it doesn’t get included by default already), by making it a prerequisite for loading your own JS.

    Sorry to dig this up from the grave, but I needed to do the same thing, this is how I did it:

    FTP to the /wp-content/plugins/wp-members/ folder or use the editor built into wordpress and edit the following files in the following way:

    In wp-members-dialogs.php find and comment out the following code (around line 696)

    if( $toggle == 'edit' ) {
    		$form = $form . '<label for="username" class="text">' . __( 'Username', 'wp-members' ) . '</label>
    
    			<div class="div_text"><p class="noinput">' .
    
    				$userdata->user_login . 
    
    			'</p></div>';
    
    	} else {
    
    		$form = $form . '<label for="username" class="text">' . __( 'Choose a Username', 'wp-members' ) . '<font class="req">*</font></label>
    
    			<div class="div_text">
    
    				<input name="log" type="text" value="' . stripslashes( $username ) . '" class="username" id="username" />
    
    			</div>';
    	}

    And in wp-members-register.php replace:

    $username = $_POST['log'];

    with

    $username = $_POST['user_email'];

    and comment out the following

    if( !validate_username( $username ) ) { $wpmem_themsg = __( 'The username cannot include non-alphanumeric characters.', 'wp-members' ); return $wpmem_themsg; exit(); }

    Upload to server/save changes.

    Plugin Author Chad Butler

    (@cbutlerjr)

    If the functions you are editing to do that are pluggable, I would highly recommend maintaining them outside the plugin (see: https://butlerblog.com/2011/11/29/customizing-wp-members-with-pluggable-functions/). That way, it will be much easier to upgrade the plugin and stay current with updates.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP-Members] Using Email for Username’ is closed to new replies.