Customize Login & Registration forms

Add addition fields to registration form

/**
 * Sample registration form fields
 */
add_action( 'sf_register_form', function() {
    ?>
    <div class="sf-form-row">
        <input type="text" name="sf-text" class="sf-test1 validate" placeholder="<?php _e( 'Text Field', 'spirit' ); ?>">
        <i class="fas fa-user"></i>
    </div>
    <div class="sf-form-row">
        <input type="tel" name="sf-tel" class="sf-tel validate" placeholder="<?php _e( 'Tel Field', 'spirit' ); ?>">
        <i class="fas fa-user"></i>
    </div>
    <div class="sf-form-row">
        <input type="number" name="sf-number" class="sf-number" placeholder="<?php _e( 'Number Field', 'spirit' ); ?>">
        <i class="fas fa-user"></i>
    </div>
    <div class="sf-form-row">
        <div class="sf-form-control sf-control-checkbox">
            <label for="sf-checkbox">
                <input type="checkbox" name="sf-checkbox" id="sf-checkbox" class="sf-checkbox">
                <span><?php _e( 'Checkbox Field', 'spirit' ); ?></span>
            </label>
        </label>
    </div>
    <div class="sf-form-row">
        <select name="sf-select" class="validate">
            <option value="">Default</option>
            <option value="1">Option 1</option>
            <option value="2">Option 2</option>
        </select>
    </div>
    <div class="sf-form-row">
        <div role="radiogroup">
            <div class="sf-form-control sf-control-radio">
                <label for="sf-male">
                    <input type="radio" id="sf-male" name="sf-radio" value="male">
                    <span>Male</span>
                </label>
            </div>
            <div class="sf-form-control sf-control-radio">
                <label for="sf-female">
                    <input type="radio" id="sf-female" name="sf-radio" value="female">
                    <span>Female</span>
                </label>
            </div>
            <div class="sf-form-control sf-control-radio">
                <label for="sf-other">
                    <input type="radio" id="sf-other" name="sf-radio" value="other">
                    <span>Other</span>
                </label>
            </div>
        </div>
    </div>
    <?php
} );

/**
 * Modify registration form error messages
 */
add_filter( 'sf_user_registration_errors', function( $errors, $fields ) {
    if ( isset( $fields['sf-radio'] ) && $fields['sf-radio'] == 'male' ) {
        // add an error message
        $errors[] = 'Only female member allowed';
        // highlight the error field
        $errors['error_fields'][] = '.sf-radio'; 
    }
    return $errors;
}, 10, 2 );

Custom login form messages

add_filter( 'sf_login_form_messages', 'custom_login_form_messages' );
/**
 * Login form messages
 *
 * $messages = array(
 *   'success' => __( 'Login successful, redirecting..', 'spirit' ),
 *   'invalid_username' => __( '<strong>ERROR</strong>: Invalid username.', 'spirit' ) . ' <a class="sf-lost-password" href="' . wp_lostpassword_url() . '">' . __( 'Lost your password?', 'spirit' ) . '</a>',
 *   'incorrect_password' => __( '<strong>ERROR</strong>: Incorrect password.', 'spirit' ) . ' <a class="sf-lost-password" href="' . wp_lostpassword_url() . '">' . __( 'Lost your password?', 'spirit' ) . '</a>',
 *   'captcha_failed' => __( 'Not a human!', 'spirit' )
 * )
 * 
 * @param array $messages
 * @return array
 */
function custom_login_form_messages( $messages ) {
    $messages['success'] = __( 'Hello world!', 'spirit' );
    return $messages;
}

Custom registration form messages

add_filter( 'sf_new_account_form_messages', 'custom_new_account_form_messages' );
/**
 * Registration form messages
 *
 * Default messages
 * $messages = array(
 *   'success'              => __( 'Registration complete. Please check your email.', 'spirit' ),
 *   'success_verify_email' => __( 'Registration complete. Please verify your email address.', 'spirit' ),
 *   'no_registration'      => __( 'User registration is currently not allowed.', 'spirit' ),
 *   'username_exists'      => __( 'Sorry, that username already exists! ', 'spirit' ),
 *   'invalid_username'     => __( 'Please enter a valid username.', 'spirit' ),
 *   'existing_user_email'  => __( 'That email is already registered, please choose another one.', 'spirit' ),
 *   'invalid_email'        => __( 'Please enter a valid email address.', 'spirit' ),
 *   'send_mail_error'      => __( 'Registration complete. System is unable to send you an email.', 'spirit' ),
 *   'captcha_failed'       => __( 'Not a human!', 'spirit' )
 * )
 * 
 * @param array $messages
 * @return array
 */
function custom_new_account_form_messages( $messages ) {
    $messages['success'] = __( 'Hello world!', 'spirit' );
    return $messages;
}

Custom lost password form messages

add_filter( 'sf_lost_password_form_messages', 'custom_lost_password_form_messages' );
/**
 * Lost password form messages
 *
 * $messages = array(
 *   success'             => __( 'Link for password reset has been emailed to you. Please check your email.', 'spirit' ),
 *   no_password_reset'   => __( 'Password reset is not allowed for this user.', 'spirit' ),
 *   user_not_registered' => __( 'There is no user registered with that email.', 'spirit' ),
 *   send_mail_error'     => __( 'System is unable to send you an email for password reset.', 'spirit' ),
 *   captcha_failed'      => __( 'Not a human!', 'spirit' )
 * )
 * 
 * @param array $messages
 * @return array
 */
function custom_lost_password_form_messages( $messages ) {
    $messages['success'] = __( 'Hello world!', 'spirit' );
    return $messages;
}