Home Knowledge Base Melapress Login Security List of hooks and shortcodes in MelaPress Login Security

List of hooks and shortcodes in MelaPress Login Security

MelaPress Login Security comes with a number of hooks and shortcodes. Hooks enable you to hook into the pluginโ€™s functionality and modify its behavior, while shortcodes enable you to display plugin elements on pages such as custom pages. This knowledge-base article documents all hooks and parameters found in MelaPress Login Security.

Melapress Login Security hooks

mls_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( 'mls_filter_allowed_special_chars', array( $this, 'special_chars_custom' ), 15, 1 );
function special_chars_custom( $chars ) {
  return str_replace( '#', '', $chars );;
}

mls_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

Example code

function example_mls_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 );
}
add_filter( 'mls_enable_custom_forms_array', 'example_mls_enable_custom_form' );

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;
}

mls_user_set_as_inactive

Function

This hook enables you to execute an action or series of actions whenever a user is set to inactive.

Parameters

$user_id – The ID of the user set to inactive

Example code

add_action( 'mls_user_set_as_inactive', 'user_set_inactive' );
function user_set_inactive( $user_id ) {
    // Your logic here, no need to return.
}

MelaPress Login Security shortcodes

Password expiry notice

Shortcode:

 [mls_user_password_expiry_notice]

Description: Use this shortcode to display a notice to users alerting them to an upcoming password expiry.

GDPR banner

Shortcode:

[mls-gdpr-banner]

Description: Use this shortcode to display the pluginโ€™s optional GDPR message.

Custom form

Shortcode:

 [mls-custom-form]ย 

Description: While you can use the mls_enable_custom_forms_array hook to apply MelaPress Login Security policy validations on custom front-end forms, you can add support for a form’s front-end PW js by passing some arguments via shortcode, as seen in the below example:

[mls-custom-form element=".my-form" button-class=".my-submit"]
Close the CTA
Were you able to find what you were looking for?