wp_register
Display the Registration or Admin link.
Description
(string|void) wp_register( $before = '<li>', $after = '</li>', (bool) $echo = true );
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.
Returns (string|void)
String when retrieving.
Parameters (3)
- 0. $before — Optional. (string) =>
'
- '
- Text to output before the link. Default
- ..
- 1. $after — Optional. (string) =>
''
- Text to output after the link. Default..
- 2. $echo — Optional. (bool) =>
true
- Default to echo and not return the link.
Usage
if ( !function_exists( 'wp_register' ) ) { require_once ABSPATH . WPINC . '/general-template.php'; } // Text to output before the link. Default `- `.
$before = '- ';
// Text to output after the link. Default ``. $after = ''; // Default to echo and not return the link. $echo = true; // NOTICE! Understand what this does before running. $result = wp_register($before, $after, $echo);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/general-template.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' ) ) {
- } 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;
- }
- }