WordPress at a glance

wp_register() WP 1.0

Display the Registration or Admin link.

Display a link which allows the user to navigate to the registration page if not logged in and registration is enabled or to the dashboard if logged in.

✈ 1 time = 0.000127s = fast | 50000 times = 3.03s = fast
Hooks from function:
Return

String/null. String when retrieving.

Usage

wp_register( $before, $after, $echo );
$before(string)
Text to output before the link.
Default: <li>
$after(string)
Text to output after the link.
Default: </li>
$echo(true/false)
Default to echo and not return the link.
Default: true

Code of wp_register: wp-includes/general-template.php VER 4.9.8

<?php
function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
	if ( ! is_user_logged_in() ) {
		if ( get_option('users_can_register') )
			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
		else
			$link = '';
	} elseif ( current_user_can( 'read' ) ) {
		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
	} else {
		$link = '';
	}

	/**
	 * Filters the HTML link to the Registration or Admin page.
	 *
	 * Users are sent to the admin page if logged-in, or the registration page
	 * if enabled and logged-out.
	 *
	 * @since 1.5.0
	 *
	 * @param string $link The HTML code for the link to the Registration or Admin page.
	 */
	$link = apply_filters( 'register', $link );

	if ( $echo ) {
		echo $link;
	} else {
		return $link;
	}
}

Related Functions

From tag: Link (tag A in HTML)

More from category: Login/Logout

More from Template Tags: Main Functions

No comments
    Hello, !     Log In . Register