Auto-generated Password

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 4, 2012   (RSS)

By gversion - April 4, 2012

Hello,

When a new user registers for an account my Membership plug-in currently emails them a very long auto-generated password. This is great, however it looks to be unnecessarily long!

Is there any where I can change how many characters the password is? Ideally I'd like it to be about 5 characters in length ,whereas currently it is about 20.

Thank you,
Greg

Re: [Tom P] Auto-generated Password

By gversion - April 4, 2012

Hi Tom,

Thanks for the quick reply.

I couldn't find the exact line you stated but I changed the number to 5 and then signed up again and the password I received was 27 characters long...

This is the line of code I changed:

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



Does it need to be changed any where else?

Thanks,
Greg

Re: [gversion] Auto-generated Password

By (Deleted User) - April 4, 2012

Hi Greg,

I need more coffee - I forgot to tell you to add a '0,' before the length of the string you wanted.

substr() takes the string (in this case, the md5 encoded uniqid() then the start position ('0' is the beginning), then the length you want.

So, what you want is :
$_REQUEST['password'] = substr(md5(uniqid(rand(), true)),0 , 5);
for a five character password.

Let me know if that helps,

Tom

Re: [Tom P] Auto-generated Password

By gversion - April 4, 2012

Hi Tom,

That's done the job!

Thanks,
Greg