Languages: English • 日本語 Русский • 한국어 • (Add your language)
This Template Tag returns the URL that allows the user to log out of the site.
<?php echo wp_logout_url( $redirect ); ?>
<a href="<?php echo wp_logout_url(); ?>">Logout</a>
If inside the loop you can use:
<a href="<?php echo wp_logout_url( get_permalink() ); ?>">Logout</a>
<a href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
If you are using wp_logout_url to redirect to another site on logout (e.g. another subsite in a MultiSite network) you'll need to make use of the allowed_redirect_hosts filter:
add_filter('allowed_redirect_hosts','allow_ms_parent_redirect'); function allow_ms_parent_redirect($allowed) { $allowed[] = 'multisiteparent.com'; return $allowed; } <a href="<?php echo wp_logout_url( 'http://multisiteparent.com' ); ?>">Logout</a>
Since: 2.7.0
wp_logout_url() is located in wp-includes/general-template.php
.
Login Tags:
is_user_logged_in(),
wp_login_form(),
wp_loginout(),
wp_logout(),
wp_register()
Login URLs:
wp_login_url(),
wp_logout_url(),
wp_lostpassword_url(),
wp_registration_url()