End of Year Sale: 30% off your first year on annual plans. Use code AP5-30-OFF See plans

WP-API custom auth

1 min read
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');
WordPress

iOS & Android app builder for WordPress

Ready to build your app?

Turn your WordPress site into iOS and Android apps with push notifications on every plan.

AppPresser End of Year Sale: 30% off AppPresser subscriptions, now through Dec 31. Two phones show sample news and events apps built with AppPresser.

End of Year Sale

30% off your first year

On Standard, Professional and Advanced annual plans. Enter the code at checkout. Ends December 31, 2026 at 11:59 PM ET.

Code AP5-30-OFF
See pricing