Created
May 31, 2016 04:00
-
-
Save justingreerbbi/c8195d280f66228f44a53cda5d1c9bfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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