Home  »  CodeLibrariesProgrammingSnippetsTechnology   »   How to Programmatically Logout in WordPress

How to Programmatically Logout in WordPress

Posted: May 11, 2022 | by Site Host

Use this code snippet to programmatically logout in WordPress.

The WordPress logout link:

<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>

WordPress programmatically logout function calls:

wp_destroy_current_session();
wp_clear_auth_cookie();
wp_set_current_user( 0 );

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Share it!

See also  How to Show or List all Branches in git