最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

logout - wp_logout hook never triggered

programmeradmin5浏览0评论

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?

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?

Share Improve this question asked Jan 10, 2022 at 18:05 assistbssassistbss 1536 bronze badges 2
  • Does the OpenID Connect Generic plugin use wp_logout() to log the user out? That appears to be the only function that fires the wp_logout action. You may need to contact the plugin's support team about this. – Pat J Commented Jan 10, 2022 at 18:28
  • OpenID Connect Generic plugin version and configuration are the same locally and on remote server. The user logout from standard toolbar (wordpress/support/article/toolbar). I can't see why there should be difference between local and remote. – assistbss Commented Jan 11, 2022 at 8:39
Add a comment  | 

1 Answer 1

Reset to default 1

On remote server I disable one by one all plugin not installed locally. Disabling maintenance plugin logout works as expected.

发布评论

评论列表(0)

  1. 暂无评论