wp_logout_url

Definition:
function wp_logout_url($redirect = '') {}

Returns the Log Out URL.
Returns the URL that allows the user to log out of the site

Parameters

  • string $redirect: Path to redirect to on logout.

Defined filters

  • logout_url
    apply_filters('logout_url', $logout_url, $redirect)

Source code

function wp_logout_url($redirect = '') {

	$args = array( 'action' => 'logout' );

	if ( !empty($redirect) ) {

		$args['redirect_to'] = urlencode( $redirect );

	}



	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));

	$logout_url = wp_nonce_url( $logout_url, 'log-out' );



	return apply_filters('logout_url', $logout_url, $redirect);

}

3889

wp_logout

Definition:
function wp_logout() {}

Log the current user out.

Defined actions

  • wp_logout
    do_action('wp_logout');

Source code

function wp_logout() {

	wp_clear_auth_cookie();

	do_action('wp_logout');

}

3887

wp_loginout

Definition:
function wp_loginout($redirect = '', $echo = true) {}

Display the Log In/Out link.
Displays a link, which allows users to navigate to the Log In page to log in or log out depending on whether they are currently logged in.

Parameters

  • string $redirect: Optional path to redirect to on login/logout.
  • boolean $echo: Default to echo and not return the link.

Defined filters

  • loginout
    apply_filters('loginout', $link)
  • loginout
    apply_filters('loginout', $link)

Source code

function wp_loginout($redirect = '', $echo = true) {

	if ( ! is_user_logged_in() )

		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';

	else

		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';



	if ( $echo )

		echo apply_filters('loginout', $link);

	else

		return apply_filters('loginout', $link);

}

3881