zanematthew/zm-ajax-login-register

[HOOK] Clean up the status filters

Closed this issue · 6 comments

This involves the pre_status as well as the status.

@mihche lets talk here. I'll push what was emailed in a bit.

@mihche

I've adjusted the code per our email. So what needs to happen for custom status is two things:

1.) Add your status to the status codes array using the filter: zm_alr_status_codes

function my_status_code_filter( $status ){

    $status['my_unique_code'] = array(
        'code'        => 'show_notice',
        'description' => __( 'Something is wrong', 'my_text_domain' ),
        'cssClass'    => 'error-container'
        );

    return $status;

}
add_filter( 'zm_alr_status_codes', 'my_status_code_filter' );

2.) Filter the pre status, add your logic, and return the status code to be used, or null if everything should proceed as normal.

function my_pre_status( $status ){

    if ( $okay ){
        // user will be logged in and signed on
        $status = null;
    }  else  {
        // something failed? User will not be logged in and message will be displayed.
        $status = 'my_unique_code';
    }

    return $status;

}
add_filter( 'zm_alr_login_submit_pre_status_error', 'my_pre_login_status' );

Note you'll also need one for the register as well add_filter( 'zm_alr_register_submit_pre_status_error', 'my_pre_login_status' );

Let me know if that works for you. I'm using it with my Google reCAPTCHA, and I'm about to add it to my email verify feature.

Perfect!
Definitely this will work

In src/ALRCore/ALRLogin.php please fix line 213:

'remember' => empty( $_POST['remember'] ) ? false : ture

Whats wrong with it? $_POST['remember']

Or are you saying it should just be changed to "rememberme", and then let wp_signon

I think this is ready to close. I have it integrated into the Pro version, and it works well with email verify, and Google reCAPTCHA.

I'm moving on to this [object object] issue #140