• I have created a custom login page as I have to have a few tasks excecuted upon login. This all works well enough, users can log in, the various tasks execute, everyone seems to have the appropriate access levels and can see the proper content on the site, etc.

    However, if you try to access /wp-admin you get logged out and sent to the (default) login page. This only happens if you originally logged in with my custom page, even if you have been logged ina and happily clicking around the site. Logging in with wp-login.php allows you to access the backend. What could I possibly missing in my login code that would cause this?

    I have tried a variety different things, but the basics are:

    $username = $wpdb->escape($_REQUEST['username']);
     $password = $wpdb->escape($_REQUEST['password']);
     $remember = false;
     if($wpdb->escape($_REQUEST['rememberme']) == 'forever') $remember = true; // forever is the value of the remember me checkbox
    
     $login_data = array();
     $login_data['user_login'] = $username;
     $login_data['user_password'] = $password;
     $login_data['remember'] = $remember;
     $user_verify = wp_signon( $login_data, true );

    I have also tried adding in:

    wp_set_current_user( $user_verify->ID, $username );
    do_action('set_current_user');

    What might I be missing? Any help is appreciated

Viewing 1 replies (of 1 total)
  • Moderator t-p

    (@t-p)

    give people some more info:

    -how did you create your custom login page?
    -Are you using a custom login plugin?
    -What is the error?
    -have you checked your error logs?
    etc.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom login – can't access admin’ is closed to new replies.