Does anybody have experience writing a custom Wordpress login page while using functions:

and wp_set_auth_cookie()

available on

I can not appear to obtain them working.

The code looks something similar to this:

function login_wordpress($username, $password) {
$creds = array();
$creds['user_login'] = $username;
$creds['user_password'] = $password;
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ) {
   echo $user->get_error_message();
else {
wp_set_auth_cookie( $user, 0, 0);


Shall We Be Held missing something fundamental?

Used to do this inside a project a couple of years back, therefore the Wordpress code was a little different. But this code labored for me personally:

// include the wordpress files necessary to run its functions
include('../classpages/wp-config.php'); // this includes wp-settings.php, which includes wp-db.php, which makes the database connection
include(ABSPATH . WPINC . '/pluggable-functions.php');

// use wordpress's function to create the login cookies
// this creates a cookie for the username and another for the hashed password, which wordpress reauthenticates each time we call its wp_get_current_user() function
wp_setcookie($user_login, $user_pass, false, '', '', $cookieuser);

I did not need to use wordpress_signon whatsoever, but that could have transformed.

Are you currently getting a mistake message, or exactly what do the thing is advertising media are your code?

You have to change this line:

wp_set_auth_cookie( $user, 0, 0);

For this:

wp_set_auth_cookie( $user->ID, 0, 0);

$user is really a WP_User Object not user id.

wp_signon returns WP_Error on failure, or WP_User on success.