Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

2 Usefull extensions

For sites where the admin do the user management, I added two functions.

1- Add button for generating password

Open yoursite.com/includes/classes/UserFields.class.php, and search for (around line 229):

 $this->html .= $this->basicInputField("user_new_password2", $locale['u135'], "64", $passRequired, "password", FALSE, "user_password");

Add the following code below:

$this->html .= $this->basicInputField("generated_password", $locale['u135b'], "100", false, $locale['u126']);

 $this->html .= "<tr>\n";
 $this->html .= "<td width='150'></td>\n";
 $this->html .= "<td width='150'><input type='button' class='btn btn-primary' value='".$locale['u135a']."' onClick='randomPassword(8);'></td></tr>\n";
 $this->html .= "<script>";
 $this->html .= "function randomPassword(length) {";
 $this->html.= "var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP1234567890';";
 $this->html .= "var pass = '';";
 $this->html .= "for (var x = 0; x < length; x++) {";
 $this->html.= "var i = Math.floor(Math.random() * chars.length);";
 $this->html .= "pass += chars.charAt(i);";
 $this->html .= "}";
 $this->html .= "inputform.user_new_password.value = pass;";
 $this->html .= "inputform.user_new_password2.value = pass;";
 $this->html .= "inputform.generated_password.value = pass;";
 $this->html .= "}";
 $this->html .= "</script>";

Now open yoursite.com/locale/English/user_fields.php and search for (arround line 78):
$locale['u135'] = "Confirm password";

add below:


$locale['u135a'] = "Generate password";
$locale['u135b'] = "Generated password";

2- Send email to member when password has changed by admin

Open yoursite.com/includes/classes/UserFieldsInput.class.php and search for (arround line 74)
private $_themeChanged = FALSE;

add below:
private $_passwordchange = FALSE;

Search for (arround line 124):

add below:
 if ($this->_passwordchange == TRUE) {
 require_once LOCALE.LOCALESET."admin/members_email.php";
 require_once INCLUDES."sendmail_include.php";

 $subject = $locale['email_passwordupd_subject'].$settings['sitename'];
 $replace_this = ["[USER_NAME]", "[PASSWORD]", "[SITENAME]", "[SITEUSERNAME]"];
 $replace_with = [$this->_userName, $this->_newUserPassword, $settings['sitename'], $settings['siteusername']];
 $message = str_replace($replace_this, $replace_with, $locale['email_passwordupd_message']);
 sendemail($this->_userName, $this->_userEmail, $settings['siteusername'], $settings['siteemail'], $subject, $message);
 $this->_passwordchange = FALSE;

Search for (arround line 275)
 if ($_isValidNewPassword === 0) {
 // New password is valid

add below
$this->_passwordchange = TRUE;

Now open yoursite.com/locale/English/admin/member_email.php and search for (arround line 1)

$locale['email_create_subject'] = "Account created at ";
$locale['email_create_message'] = "Hello [USER_NAME],<br/>\r\n
Your account at [SITENAME] has been created.<br/>\r\nYou can now login using the following details:<br/>\r\n
Username: [USER_NAME]<br/>\r\nPassword: [PASSWORD]<br/>\r\nRegards,<br/>\r\n[SITEUSERNAME]";

add below

$locale['email_passwordupd_subject'] = "Password changed at ";
$locale['email_passwordupd_message'] = "Hello [USER_NAME],\n
Your password has been succesfully updated<br>Y\r\nYou can now login using the following details:<br/>\r\n
Username: [USER_NAME]<br/>\r\nPassword: [PASSWORD]<br/>\r\nRegards,<br/>\r\n[SITEUSERNAME]";

Very good. I added these codes to my new v8 system. Works great!

I was struggling the hole time with user passwords, so I made this. Maybe it can be included in future versions of PF.
Really nice extensions! If a user lost his password and can not for some reason use lostpassword I set it default to welcome+alittleextra and send him/her a mail. This is far more professional and easier!
Incredible Douwe_Yntema, thanks for sharing. Please, please do keep sharing these, Infusions, Panels, and more too. I LOVE your work, it is FANTASTIC.
Thread Information
6 posts
201 times
Last Post
Last updated on 18 days ago
Related Threads
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Wanabo, Grimloch, douwe_yntema, SkeeredOfMyMind