WebsiteMembership Plugin - Non Generated Password

By chrisl - February 9, 2010

Hi

Love this plugin and would encourage others to use.

Right now I have it set with the email being the username and the program sending a password over to user. QUESTION: A few members are getting confused with the process (don't get me started) so is it possible to have the user fill in the signup.php with both the username and password thereby avoiding the email part of the process?
cj

Re: [chrisl] WebsiteMembership Plugin - Non Generated Password

By Chris - February 11, 2010

Hi chrisl,

The existing process has the advantage of making sure that users have supplied real email addresses. If they specify a fake email, they won't receive their temporary password.

If you want to change things, it'll require some coding...

The password is generated by this line in sample_signup.php:

$_REQUEST['password'] = substr(md5(uniqid(rand(), true)), 15); // example output: c5560251ef0b3eef9

If you remove that line and add an <input> in your form for "password", users will be able to supply their own passwords. You'd also want to add some validation checks to make sure people type in a password. You may want to add a "Password again" feature too to make sure people don't mistype their password.

If you want to prevent the email from being sent, simply remove this line:

_websiteLogin_sendSignupMessage();

You'll also want to update the "thanks" message to reflect that no email has been sent.

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] WebsiteMembership Plugin - Non Generated Password

By chrisl - February 11, 2010

Yes I see the logic in the way it is designed. I will not amend it. The statement $_REQUEST['password'] = substr(md5(uniqid(rand(), true)), 15); // example output: c5560251ef0b3eef9 - is the "15" the command that generates the length of the password (trying to simplify it for our members)? So if you replace 15 with say 5 it would generate a shorter password?
cj

Re: [chrisl] WebsiteMembership Plugin - Non Generated Password

By Chris - February 11, 2010 - edited: February 11, 2010

Hi chrisl,

Almost. The 15 skips the first 15 characters of the 32 characters returned by md5(), resulting in a 17 character string. To get 5 characters, try this:

$_REQUEST['password'] = substr(md5(uniqid(rand(), true)), 0, 5); // example output: c5560

That's a great solution. :)
All the best,
Chris

Re: [chris] WebsiteMembership Plugin - Non Generated Password

By chrisl - February 11, 2010

Outstanding. Works like a charm.
cj