Wednesday 23 September 2015

login with ajax in wordpress




Remember me

// add jquery and ajax call






 <?php

/*Start Login*/

if(!empty($_POST['username']) && !empty($_POST['password']) && $_POST['action'] == "login"){
    $info = array();
    $info['user_login'] = $_POST['username'];
    $info['user_password'] = $_POST['password'];
    $info['remember'] = $_POST['remember'];
    $user = get_userdatabylogin($_POST['username']);
    $CheckMeta = get_user_meta($user->ID, 'has_to_be_activated', true);
    $user_signon = wp_signon( $info, false );
    if ( is_wp_error($user_signon) ){
       echo  '

Wrong username or password

'; }else if ($CheckMeta) { echo '

User is not activated. please go and activate

'; }else { echo '

Login successful, redirecting...

'; } } /*End Login*/ ?>

No comments:

Post a Comment