Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save justingreerbbi/c8195d280f66228f44a53cda5d1c9bfc to your computer and use it in GitHub Desktop.
Save justingreerbbi/c8195d280f66228f44a53cda5d1c9bfc to your computer and use it in GitHub Desktop.
add_filter( 'wo_endpoints', 'wo_extend_endpoints' );
function wo_extend_endpoints ( $endpoints ){
$endpoints = array(
'is_logged_in' => array(
'func' => '_wo_is_logged_in_wo7391',
'public' => false
)
);
return $endpoints;
}
function _wo_is_logged_in_wo7391( $token = null ){
if ( !isset( $token['access_token'] ) ) {
$response = new OAuth2\Response();
$response->setError( 400, 'invalid_request', 'Missing access token' );
$response->send();
exit;
}
$access_token = $token['access_token'];
global $wpdb;
$stmt = $wpdb->get_row("SELECT expires FROM {$wpdb->prefix}oauth_access_tokens WHERE access_token={$access_token}");
// Check the expires time against the current time and return if the token is valid or not.
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment