Search for answers or browse our knowledge base.
List of hooks in Melapress Login Security
Melapress Login Security hooks allow you to hook into the plugin’s functionality and modify its behavior. This knowledge base article documents all hooks and parameters found in Melapress Login Security.
Index of hooks:
Melapress Login Security hooks
ppwmp_filter_allowed_special_chars
Function
This hook allows you to alter the list of special characters used in password policies. With this hook, you could, for instance, allow the hash character to be used by users when setting their passwords. It offers a single parameter which is the string of default characters and an example of its use can be seen below
Parameters
$chars – Special characters you want to allow
Example code
add_filter( 'ppwmp_filter_allowed_special_chars', array( $this, 'special_chars_custom' ), 15, 1 ); // From here we can modify the string as we see fit with the following function special_chars_custom( $chars ) { return str_replace( '#', '', $chars ); }
ppm_enable_custom_forms_array
Function
This hook allows you to apply any Melapress Login Security policy validations to custom front-end forms. Forms inputs/fields can be targeted using CSS selectors.
In the code example given below, we first add the filter and then assign our custom function. Then, we pass the parameters through the $args array, to which we append our parameters.
Parameters
$args – An array of parameters that includes:
-
- form_selector – The unique class or ID given to the overall form element itself; the following items are child objects of this form.
- pw_field_selector – The selector of the form element you wish to apply the PPMWP JS to.
- form_submit_selector – The selector for the “submit” button of your form, which is used to apply “disable.” This stops the form from being submitted whilst an invalid password is present.
- elements_to_hide – The selector for any elements you wish to remove from the user’s view. This is ideal for hiding unwanted “password hints,” leaving just the hints provided by our plugin in their place
- form_selector – The unique class or ID given to the overall form element itself; the following items are child objects of this form.
Example code
add_filter( 'ppm_enable_custom_forms_array', 'example_ppm_enable_custom_form' ); function example_ppm_enable_custom_form_array( $args ) { $new = array( array( 'form_selector' => '.lost_reset_password', 'pw_field_selector' => '#password_1', 'form_submit_selector' => '#submit_password', 'elements_to_hide' => '#old_pw_hints', ), ); return array_merge( $args, $new ); }
mls_override_has_expired_priority”
Function
This hook allows you to set the priority of the has_expired function within WordPress’ login processes. The hook runs on WordPress’ own ‘wp_authenticate_user’ hook. The default priority is 10; however, this hook allows you to change that.
Parameters
Default – 10. The lower the number the higher the priority.
Example code
add_filter( 'mls_override_has_expired_priority', 'override_has_expired_priority' ); function override_has_expired_priority() { return 10; }