WordPress at a glance

wp_loginout() WP 1.0

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.

✈ 1 time = 0.000138s = fast | 50000 times = 3.67s = fast | PHP 7.0.2, WP 4.4.2
Hooks from the function
Return

String/null. String when retrieving.

Usage

wp_loginout( $redirect, $echo );
$redirect(string)
Optional path to redirect to on login/logout.
Default: ''
$echo(true/false)
Default to echo and not return the link.
Default: true

Changelog

Since 1.5.0 Introduced.

Code of wp loginout: wp-includes/general-template.php WP 5.2.4

<?php
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 ) {
		/**
		 * Filters the HTML output for the Log In/Log Out link.
		 *
		 * @since 1.5.0
		 *
		 * @param string $link The HTML link content.
		 */
		echo apply_filters( 'loginout', $link );
	} else {
		/** This filter is documented in wp-includes/general-template.php */
		return apply_filters( 'loginout', $link );
	}
}

Related Functions

From category: Login/Logout

More from Template Tags: Main Functions

No comments
    Hello, !     Log In . Register