Check Password While User Account Creation
Jamroom Developers
You definitely don't want to modify the jrUser module - there's no need to. Instead you want to create your own custom small module that has an event listener inside that watches for signups and can check the incoming password for whatever rules you would like. Something like this:
1) Create a new directory in your modules directory called "pwCheck" or whatever you want to call it.
2) create a new file inside that directory called "include.php" with the following inside:
<?php
// Meta data about our module
function pwCheck_meta()
{
$_tmp = array(
'name' => 'Password Checker',
'url' => 'pwcheck',
'version' => '1.0.0',
'developer' => 'Your Name',
'description' => 'Checks users passwords on signup',
'category' => 'users'
);
return $_tmp;
}
// Init function
function pwCheck_init()
{
jrCore_register_event_listener('jrCore', 'form_validate_exit', 'pwCheck_listener');
return true;
}
// Validate password field after core has validated other fields
function pwCheck_listener($_data, $_user, $_conf, $_args, $event)
{
global $_post;
if ($_post['module'] == 'jrUser' && $_post['option'] == 'signup_save') {
// We have a new user creating an account - check password
if ($_post['user_passwd1'] != 'abcdefg') {
jrCore_set_form_notice('error', 'Your password is not abcdefg!');
jrCore_form_field_hilight('user_passwd1');
jrCore_form_field_hilight('user_passwd2');
jrCore_form_result();
}
}
return $_data;
}
?>Just adjust this part:
if ($_post['user_passwd1'] != 'abcdefg') {to suit your needs.
3) You can add a small “icon.png” file in the same directory if you’d like an icon in ACP.
Hope this helps!
updated by @brian: 03/18/14 06:26:47AM
Am I in the wrong place? Thanks