On this page
wp_logout_url( string $redirect = '' ): string
Retrieves the logout URL.
Description
Returns the URL that allows the user to log out of the site.
Parameters
$redirectstring Optional-
Path to redirect to on logout.
Default:
''
Return
string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url() .
Source
File: wp-includes/general-template.php. View all references
function wp_logout_url( $redirect = '' ) {
$args = array();
if ( ! empty( $redirect ) ) {
$args['redirect_to'] = urlencode( $redirect );
}
$logout_url = add_query_arg( $args, site_url( 'wp-login.php?action=logout', 'login' ) );
$logout_url = wp_nonce_url( $logout_url, 'log-out' );
/**
* Filters the logout URL.
*
* @since 2.8.0
*
* @param string $logout_url The HTML-encoded logout URL.
* @param string $redirect Path to redirect to on logout.
*/
return apply_filters( 'logout_url', $logout_url, $redirect );
}
Hooks
- apply_filters( 'logout_url',
string $logout_url ,string $redirect ) -
Filters the logout URL.
Related
Uses
| Uses | Description |
|---|---|
| site_url() wp-includes/link-template.php | Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. |
| wp_nonce_url() wp-includes/functions.php | Retrieves URL with nonce added to URL query. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| wp_loginout() wp-includes/general-template.php | Displays the Log In/Out link. |
| wp_nonce_ays() wp-includes/functions.php | Displays “Are You Sure” message to confirm the action being taken. |
| WP_Admin_Bar::_render() wp-includes/class-wp-admin-bar.php | |
| wp_admin_bar_my_account_menu() wp-includes/admin-bar.php | Adds the “My Account” submenu items. |
| comment_form() wp-includes/comment-template.php | Outputs a complete commenting form for use within a template. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_logout_url