WP-API custom auth
- function checkApiAuth( $result ){
- // if user and token from app match user meta in wp, continue
- $app_token = $_GET['app_token'];
- $user_id = $check_user_id;
- $wp_token = get_user_meta( $user_id, 'app_token', true);
- if( empty( $app_token ) )
- $result = false;
- if( $wp_token === $app_token )
- $result = true;
- return $result;
- }
- add_filter('json_authentication_errors', 'checkApiAuth');
March 5, 2015