WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Object of class WP_User could not be converted to string (2 posts)

  1. Phil.trash
    Member
    Posted 4 years ago #

    Hi everyone,

    Little issue when I try to create a registration page, I create a new user and then try to log him directly and redirect to the last page, here's the code I use:

    $creds = array();
    $creds['user_login'] = $user_login;
    $creds['user_password'] = $user_pass;
    $creds['remember'] = true;
    
    $user = wp_signon( $creds, false);

    I get this error:
    PHP Catchable fatal error: Object of class WP_User could not be converted to string in /wp-content/themes/mytheme/register_data.php on line 40
    (Line 40 being the $user = wp_signon( $creds, false);

    Thanks!

  2. Phil.trash
    Member
    Posted 4 years ago #

    My bad, I didn't add the "wp-blog-header.php" file..

    require('./wp-blog-header.php');
    
    require_once( ABSPATH . WPINC . '/registration.php');
    require_once( ABSPATH . WPINC . '/user.php');

Topic Closed

This topic has been closed to new replies.

About this Topic