I'm writing a plugin for WordPress, in procedural PHP.
Anyway, in the plugin, I want to update a users WordPress Session Token
, which is stored in the usermeta
table.
Digging around, I've found a class which has some methods which I think will help me achieve my goal.
I've written a function, which has the correct data, updates the expiry time, and I'm just attempting to pass the update through WP_Session_Tokens
.
But I get the error:
Using $this when not in object context in .../wp-includes/class-wp-session-tokens.php on line 166
My function is so:
function update_auth_cookie($user_login, $user) {
$options = get_option('options_premium');
$cookieTime = $options['cookieTime'];
$sessionToken = wp_get_session_token();
$verifier = hash('sha256', $sessionToken);
$sessions = get_user_meta($user->ID, 'session_tokens', true);
$sessions[$verifier]['expiration'] = $cookieTime;
WP_Session_Tokens::update( $verifier, $sessions[$verifier]);
}
add_action('auth_cookie_valid', 'update_auth_cookie', 10, 2);
Is it possible to access a class through a function like this? If so, is it obvious what I'm doing wrong?