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):

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



Add the following code below:

CodeDownload  
$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):
CodeDownload  
$locale['u135'] = "Confirm password";



add below:

CodeDownload  

$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)
CodeDownload  
private $_themeChanged = FALSE;



add below:
CodeDownload  
private $_passwordchange = FALSE;



Search for (arround line 124):
CodeDownload  
$this->_setCustomUserFieldsData();



add below:
CodeDownload  
 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)
CodeDownload  
 if ($_isValidNewPassword === 0) {
 // New password is valid



add below
CodeDownload  
$this->_passwordchange = TRUE;



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

CodeDownload  
$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
CodeDownload  

$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!
Thanks,

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!
Exactly
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
Author
Replies
6 posts
Views
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