Site icon Hip-Hop Website Design and Development

wp_signon gives error insufficient_permissions

This seems odd to me because if you’re signing on a user you shouldn’t already be signed in… therefore your permissions shouldn’t matter.

It may be a bit of an odd way of going about it, so that could be causing the issue. Here’s the code:

function login( $user_name, $password ) {
    $creds = array();
    $creds['user_login'] = $user_name;
    $creds['user_password'] = $password;
    $creds['remember'] = false;

    $user = wp_signon( $creds, true );

    if( is_wp_error( $user ) ) {
        $result = $user;
    }
    else {
        /* do some other stuff */
    }

    return $result;
}

This is found on a separate page used for web services… this page loads the proper WordPress functions with:

require_once('../../../../../wp-load.php');

And is posted to via jQuery from the front end.

Worth noting that other WP functions such as interaction with global $wpdb works in this file.