LoginSignup
2
3

More than 5 years have passed since last update.

Wordpressで特定のユーザーを強制的にログアウトさせる方法(ID指定)

Posted at

会員制サイトを構築する際、とある理由で特定のユーザーを強制ログアウトさせる機能が必要になった。
ってーことでちょっと調べた結果、下記の関数で実現できた。

delete_user_meta( $user_id, 'session_tokens' );

参考ソースはwp-includes/class-wp-user-meta-session-tokens.phpの94~99行目。
usermetaテーブルのmeta_keyがsession_tokensっていうレコードがあったので、もしかしてと思って検索したらビンゴでしたとさ。

そもそもWordpressで会員制サイトってどうなんだという話は隅においておく。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3