wp_loginout
Display the Log In/Out link.
Description
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.
Returns (string|void)
String when retrieving.
Parameters (2)
- 0. $redirect — Optional. (string) =>
''
- Path to redirect to on login/logout.
- 1. $echo — Optional. (constant) =>
true
- Default to echo and not return the link.
Usage
if ( !function_exists( 'wp_loginout' ) ) { require_once ABSPATH . WPINC . '/general-template.php'; } // Optional path to redirect to on login/logout. $redirect = ''; // Default to echo and not return the link. $echo = true; // NOTICE! Understand what this does before running. $result = wp_loginout($redirect, $echo);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/general-template.php
- function wp_loginout($redirect = '', $echo = true) {
- if ( ! is_user_logged_in() )
- else
- 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 );
- }
- }