I have WordPress with WooCommerce installed and I am trying to use this code to login an admin user:

if ( !is_user_logged_in() ) {
    $user = get_userdatabylogin( $username );
    $id = $user->ID;

    wp_set_current_user( $id, $user->user_login );
    wp_set_auth_cookie( $id );
    do_action( 'wp_login', $user->user_login );
}

But it is returning this error message:

Warning: Missing argument 2 for wc_maybe_store_user_agent() in /home/i/n/username/public_html/shop/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1516

I have tried looking around online but no one seems to have had this issue.

Read more here: WP/WC missing arguement in WC Function


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: