Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created September 7, 2022 22:48
Show Gist options
  • Save nikitasinelnikov/85ca437e9254afa522a63b42ed4fd034 to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/85ca437e9254afa522a63b42ed4fd034 to your computer and use it in GitHub Desktop.
Ultimate Member v3: Password Reset 'um_lostpassword_form_args' hook
// 'um_reset_password_page_hidden_fields' - use filter's hook `um_lostpassword_form_args` instead and add the hiddens to it
// 'um_after_password_reset_fields' - use filter's hook `um_lostpassword_form_args` instead and add the fields to it
/**
* Description: Fires before rendering the lost password form and filters the lost password arguments.
* This hook may be used to add custom hidden fields or display custom content in the password reset form header.
*
* Hook: um_lostpassword_form_args
*
* Type: filter
*
* @package um\core
* @since 3.0.0
*
* @param array $args Lost Password form arguments necessary for init form.
*/
function mylostpassword_form_args( $args ) {
// default array for the arguments.
/* $args = array(
'id' => 'um-lostpassword',
'class' => 'um-top-label um-center-always',
'prefix_id' => '',
'fields' => array(
array(
'type' => 'text',
'label' => __( 'Username or Email Address', 'ultimate-member' ),
'id' => 'user_login',
'required' => true,
'value' => '',
'placeholder' => __( 'Enter Username or Email Address', 'ultimate-member' ),
'validation' => 'user_login',
)
),
'hiddens' => array(
'um-action' => 'password-reset-request',
'nonce' => wp_create_nonce( 'um-lostpassword' ),
),
'buttons' => array(
'new-password' => array(
'type' => 'submit',
'label' => __( 'Get New Password', 'ultimate-member' ),
),
),
); */
// you may change hiddens for this form
$args['hiddens']['{hidden_name}'] = '{hidden value}';
// you may add fields to this form
$args['fields'][] = array(
// {field data} see necessary arguments for the fields in ultimate-member/includes/frontend/class-form.php
// 'id' and 'type' are required
);
return $args;
}
add_filter( 'um_lostpassword_form_args', 'mylostpassword_form_args', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment