How to Logout Users from WordPress Using a Custom Link - ProfilePress

How to Logout Users from WordPress Using a Custom Link

In the past, we covered how to add registration, login and Logout links to WordPress Menu.
In this article, i will be showing us how to create a logout link or URL which which clicked or opened, log out users from your WordPress powered site.

This can be achieved with ProfilePress [link-logout] shortcode in two ways;

Method I

Firstly is via [link-logout id="" class="" label="Sign Out" title=""] which output or display a link which when clicked, log out the user.

Pasting the above shortcode in a post or page will create a link with anchor text set to “Sign Out” like so:

<a href=”” title=”Sign Out” class=”logout” id=”log-out”>Sign Out</a>

Note: the shortcode attributes are optional. For example, leaving out the label attribute will cause the anchor text to be “Log Out”.

Method II

Another way is by adding “raw” to the shortcode like so [link-logout raw].
Saving the above shortcode to a page will cause users to be logged out when they try to visit or access the page URL.

Note: this differs from the first method in that it does not display an HTML link that has to be clicked before users are logged out.

I hope this helps.