Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › eMember – want to use email as username
Tagged: change user name, email, email username, registration, username
- This topic has 29 replies, 14 voices, and was last updated 7 years, 6 months ago by admin.
-
AuthorPosts
-
February 26, 2012 at 12:27 am #5662SanDiegoWebGuyMember
I want to lift the restrictions on my site so the user doesn’t see “User (email):Only Letter, Number and Underscore allowed. ” when they use their email as the username.
Essentially, I want subscribers to use their email as a username, so they don’t need to remember yet another username.
February 26, 2012 at 11:18 pm #42363adminKeymasterUpdate: We now have a couple of features that will allow you to do this. The later posts in this topic has more info on it.
We don’t have this option. eMember integrates with WordPress users database and the affiliate plugin so we need to keep the “username” field’s character set limited to what both the WordPress users database and the affiliate plugin will accept.
March 4, 2012 at 6:17 pm #42364SanDiegoWebGuyMemberI was able to modify the registration page myself. I simply forced it to validate that the username was an email and modified the email field, which now validates as equal to the the user name field, and [strong]disabled[/strong] the plug-in’s ability to create a WordPress account. Without that, there’s no longer a conflict. I also added a second password field to verify the password.
If you’re interested in what/where, here’s the scoop:
open wp-eMembereMember_registration_utils.php
Find the eMember rego form, around line 592.
<table width="95%" border="0" cellpadding="3" cellspacing="3" class="forms">
<tr>
<td><label for="wp_emember_user_name" class="eMember_label"><?php echo EMEMBER_USERNAME;?>: </label></td>
<td><input type="text" id="wp_emember_user_name" name="wp_emember_user_name" size="20" value="<?php echo $_POST['wp_emember_user_name'];?>" class="validate[required,custom[onlyLetterNumberUnderscore],minSize[4]<?php echo $letter_number_underscore?>,ajax[ajaxUserCall]] eMember_text_input" /></td>
</tr>
<tr>
<td><label for="wp_emember_pwd" class="eMember_label"><?php echo EMEMBER_PASSWORD;?>: </label></td>
<td><input type="password" id="wp_emember_pwd" name="wp_emember_pwd" size="20" value="<?php echo $_POST['wp_emember_pwd'];?>" class="validate[required,minSize[4]] eMember_text_input" /></td>
</tr>
<tr>
<td><label for="wp_emember_email" class="eMember_label"><?php echo EMEMBER_EMAIL;?>: </label></td>
<td><input type="text" id="wp_emember_email" name="wp_emember_email" size="20" value="<?php echo $_POST['wp_emember_email'];?>" class="validate[required,custom[email]] eMember_text_input" <?php echo $readonlyemail; ?> /></td>
</tr>…and replace the code above with this:
<table width="95%" border="0" cellpadding="3" cellspacing="3" class="forms">
<tr>
<td><label for="wp_emember_user_name" class="eMember_label"><?php echo EMEMBER_USERNAME;?>: *</label></td>
<td><input type="text" id="wp_emember_user_name" name="wp_emember_user_name" size="20" value="<?php echo $_POST['wp_emember_user_name'];?>" class="validate[required,custom[/email][email]] eMember_text_input" /></td>
</tr>
<tr>
<td><label for="wp_emember_email" class="eMember_label"><?php echo EMEMBER_EMAIL;?>: *</label></td>
<td><input type="text" id="wp_emember_email" name="wp_emember_email" size="20" value="<?php echo $_POST['wp_emember_email'];?>" class="validate[required,custom[/email][email],equals[wp_emember_user_name]] eMember_text_input" <?php echo $readonlyemail; ?> /></td>
</tr>
<tr>
<td><label for="wp_emember_pwd" class="eMember_label"><?php echo EMEMBER_PASSWORD;?>: *</label></td>
<td><input type="password" id="wp_emember_pwd" name="wp_emember_pwd" size="20" value="<?php echo $_POST['wp_emember_pwd'];?>" class="validate[required,minSize[4]] eMember_text_input" /></td>
</tr>
<tr>
<td><label for="wp_emember_pwd_r" class="eMember_label"><?php echo EMEMBER_PASSWORD_REPEAT ?>: *</label></td>
<td><input type="password" id="wp_emember_pwd_r" name="wp_emember_pwd_r" size="20" value="" class="validate[equals[wp_emember_pwd]] eMember_text_input" />
</td>[/email]
March 21, 2012 at 6:56 pm #42365ferrallradioMemberHi SanDiegoWebGuy,
I’ve implemented your change but am still getting the message that I am using illegal characters in the username. The plugins ability to create WP account has been disabled and I’ve toggled to make sure there wasn’t a bad cache or anything.
Thanks
February 7, 2013 at 8:40 pm #42366ashleyseagrapeMemberHello,
I have tried this code and I am running into the same issue as @ferrallradio.
I am able to enter in an email address as the username without the field pop up message, but once I click the Register button, an error messages appears at the top of the form: “Username:Only Letter, Number and Underscore allowed.”
I have also done the regex alterations suggested in this post to allow all characters: https://support.tipsandtricks-hq.com/forums/topic/spaces-hyphens-and-commas-in-username
My updated regex line looks like this:
"onlyLetterNumberUnderscore": {
"regex": /^[.]+$/,
"alertText": "* "+'<?php echo EMEMBER_ALPHA_NUMERIC_UNDERSCORE;?>'
Is this correct? What am I missing to allow email addresses to be used as the username?
Thanks in advance!
February 8, 2013 at 5:24 am #42367nurMemberThere is one more thing to do before you can use email as user name. for that, open eMember_registration_utils.php and search for the following line of code:
$validator->add(array('value'=>$_POST['wp_emember_user_name'],'label'=>EMEMBER_USERNAME,'rules'=>array('user_required','user_minlength','alphanumericunderscore','user_unavail')));
Once you find it, remove “alphanumericunderscore” from rules list. This should allow you to register using email in the username field.
Hope this helps.
February 8, 2013 at 6:36 pm #42368ashleyseagrapeMemberAwesome!! That totally worked! Thanks so much for your help.
I also have a related question. Not sure if I should start a new thread for this or not..
Now that the Username can be an email address, is it possible to have the Username field automatically filled with the email address the same way the email address field is auto filled?
I am using the “confirm email address” option, so I am referring to the registration page you get to from the link in the email.
Thanks again!
February 8, 2013 at 6:43 pm #42369ashleyseagrapeMemberOh I just figured it out… I just replaced:
value=”<?php echo $_POST;?>”
with
value=”<?php echo $_POST;?>”
Thanks again for your help!!
January 20, 2014 at 10:55 am #42370mattbarryMemberDoes this still work in the latest release of the plugin? I have tried it but the ‘Only letters,numbers etc is allowed’ message still pops up.
January 21, 2014 at 3:12 am #42371adminKeymasterWe are actually going to make this an option in our plugin soon. So don’t worry about doing any tweaks now. Just wait for a week then we should have that work done.
January 21, 2014 at 11:22 am #42372mattbarryMemberExcellent! Thank you
January 22, 2014 at 8:46 pm #42373ckoMemberperfect, waiting for it – how can i get the update when it’s ready?
February 20, 2014 at 10:13 pm #42374robthecomputerguyMemberI’m on 8.8.2 currently but I don’t see this feature listed yet, can I find out if it’s been added yet?
SOOOOOOOOO excited about having this built in.
Thanks!!
February 22, 2014 at 2:54 am #42375adminKeymasterWe are going to turn it on by default in our next version. So that username field will also allow email address values (in addition to everything else it used to accept).
March 21, 2014 at 8:40 pm #42376mauro7219MemberHello to all. I’m a big fan of emember. When will it possible login with the email?
-
AuthorPosts
- You must be logged in to reply to this topic.