'Login user programatically in BBPress
I am trying to log in a user programmatically in bbpress, I tried logging the user in in wordpress with the following code snippet:
$username = "Carlos";
$user = get_user_by('login', $username );
$user_id = $user->ID;
clean_user_cache($user->ID);
wp_clear_auth_cookie();
wp_set_current_user( $user_id, $user->user_login );
wp_set_auth_cookie( $user_id, true, true );
update_user_caches( $user );
This seems to work, when I echo is_user_logged_in() it returns true. But the user is not logged in within the bbpress forum.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
