Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
28.2k views
in Q2A Core by

On the registration page I want to display a note under Password saying something like: "Password must contain at least 1 number, 1 small letter, 1 capital letter and 1 special character.". It  should be similar with the note under email: "Privacy: Your email address will not be shared or sold to third parties."

In order to implement this thing I have done below changes but I'm afraid it is not enough :(.

In qa-include/lang/qa-lang-options.php i have added the line:

'password_rules' => 'Password must contain at least 1 number, 1 small letter, 1 capital letter and 1 special character.',

In qa-include/app/options.php i have added below lines: 

case 'password_rules':
$value = qa_lang_html('options/password_rules');
break;

In qa-include/pages/register.php i have added note as you can see below in yellow:

'password' => array(
'type' => 'password',
'label' => qa_lang_html('users/password_label'),
'tags' => 'name="password" id="password" dir="auto" autocomplete="off"',
'value' => qa_html(@$inpassword),
'note' => qa_opt('password_rules'),
'error' => qa_html(@$errors['password']),
),

Can you please tell me what else I must change?

Note: It will be great if you can share a solution to display the note on all pages where password can be set or changed but this is more a nice to have thing.

Q2A version: 1.8

1 Answer

+1 vote
by
selected by
 
Best answer

Try this.

Create a custom plugin with only layer.php file. Plugin will have these files:

- qa-plugin.php

- my-layer.php

The qa-plugin.php should look like this:

<?php

if(!defined('QA_VERSION'))

{

header('Location: ../../');

exit;

}

// layer 

qa_register_plugin_layer('my-layer.php', 'my layer');

The my-layer.php file should look like this:

<?php

class qa_html_theme_layer extends qa_html_theme_base

{

public function form_password($field, $style)

{

qa_html_theme_base::form_password($field, $style);

if ($this->template == 'register' && $field['type'] == 'password') {

$field['note'] = 'Password must contain at least 1 number, 1 small letter, 1 capital letter and 1 special character.';

$this->form_note($field, 'tall', 1);

}

}

This will be a custom plugin that will do your plan.

Let me know if it works.

by
it worked...thank you very much! :)
...