wp_logout triggers php error 500

[ad_1]

hi! i created a custom rest endpoint to logout the current user:

function _api_logout()
{
    wp_logout();

    return [
        'id' => 0,
        'nonce' => wp_create_nonce('wp_rest')
    ];
}

function _rest_api_init()

    register_rest_route(
        'oink/v1',
        '/logout',
        [
            'methods' => 'GET',
            'callback' => '_api_logout',
            'permission_callback' => '__return_true'
        ]
    );
}

add_action('rest_api_init', '_rest_api_init');

that works fine, as long as i deactivate this plugin. with aios active, i get following php errors:

[01-Mar-2024 08:56:39 UTC] PHP Warning:  Attempt to read property "ID" on bool in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php on line 652
[01-Mar-2024 08:56:39 UTC] PHP Warning:  Attempt to read property "ID" on bool in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php on line 656
[01-Mar-2024 08:56:39 UTC] PHP Warning:  Attempt to read property "ID" on bool in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php on line 658
[01-Mar-2024 08:56:39 UTC] PHP Warning:  Attempt to read property "ID" on bool in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php on line 661
[01-Mar-2024 08:56:39 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function get_active_blog_for_user() in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php:678
Stack trace:
#0 /wp/wp-includes/class-wp-hook.php(324): AIOWPSecurity_User_Login->wp_logout_action_handler()
#1 /wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#2 /wp/wp-includes/plugin.php(517): WP_Hook->do_action()
#3 /wp/wp-includes/pluggable.php(671): do_action()
#4 /app/themes/blank/inc/api.php(267): wp_logout()
#5 /wp/wp-includes/rest-api/class-wp-rest-server.php(1193): blank_api_logout()
#6 /wp/wp-includes/rest-api/class-wp-rest-server.php(1041): WP_REST_Server->respond_to_request()
#7 /wp/wp-includes/rest-api/class-wp-rest-server.php(431): WP_REST_Server->dispatch()
#8 /wp/wp-includes/rest-api.php(424): WP_REST_Server->serve_request()
#9 /wp/wp-includes/class-wp-hook.php(324): rest_api_loaded()
#10 /wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#11 /wp/wp-includes/plugin.php(565): WP_Hook->do_action()
#12 /wp/wp-includes/class-wp.php(418): do_action_ref_array()
#13 /wp/wp-includes/class-wp.php(813): WP->parse_request()
#14 /wp/wp-includes/functions.php(1336): WP->main()
#15 /wp/wp-blog-header.php(16): wp()
#16 /index.php(6): require('...')
#17 {main}
  thrown in /app/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-user-login.php on line 678

not sure, what causes the issue. if you need to know certain settings or whatever, please let me know..

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer