Long story short.
In wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
In the main file of my plugin, in the constructor:
public function __construct(){
error_log("this is properly logged");
add_action( 'wp_logout', array($this, 'logout') );
}
Then the logout method:
public function logout(){
error_log("never logged");
}
The logout method is never executed. Why?
The whole story
I allow user to signin/signup using OpenID Connect Generic plugin.
Locally everything works as expected.
On remote server I encountered problem only with logout.
If I manually reach the endpoint related to logout, the session is properly closed on the identity provider. But when user logout from wordpress the endpoint is not reached. Indeed at login, after logout, previous user’s session is restored without asking for credentials.
Thinking about an OpenID Connect Generic issue I tried to reach the endpoint programmatically on logout hook. Nothing appens, so I tried to debug putting some error_log in logout method, but they are never executed, so wp_logout hook is never triggered at all. Why?