<span class="resolved" aria-label="Resolved" title="Topic is resolved."></span>Autologin

[ad_1]

Replies: 0

When I call the website via Get parameter with token I want to be logged in automatically.

Is there a function in the framework which validates from the token and returns the user id.
Unfortunately I did not find anything.

I would have thought something like this code:
$user_id = WPO_Auth_Code::authenticate_token($_GET[‘token’]);

Here is the code how I want to realize this:

add_action(‘init’, ‘authenticate_user_with_token’); function authenticate_user_with_token() { // Check if token is present in GET parameter if (isset($_GET[‘token’])) { // Load WP OAuth Server class if (!class_exists(‘WPO_Auth_Code’)) { require_once(‘wp-content/plugins/wp-oauth-server/includes/class-wpoauth-code.php’); } // Authenticate token and get user ID $user_id = WPO_Auth_Code::authenticate_token($_GET[‘token’]); // Check if user ID is valid if ($user_id) { // Set authentication cookie for the user wp_set_auth_cookie($user_id); } } }

  • This topic was modified 1 minute ago by xandreasjuenx.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer