wp_register( string $before = '<li>', string $after = '</li>', bool $echo = true )
Display the Registration or Admin link.
Description Description
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.
Parameters Parameters
- $before
-
(string) (Optional) Text to output before the link. Default
<li>
.Default value: '<li>'
- $after
-
(string) (Optional) Text to output after the link. Default
</li>
.Default value: '</li>'
- $echo
-
(bool) (Optional) Default to echo and not return the link.
Default value: true
Return Return
(string|void) String when retrieving.
Source Source
File: 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' ) ) { $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; } }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Default Usage
wp_register
displays the link in list format<li>
.Display Without Text Before or After
The following code example displays the “Register” or “Site Admin” link with no text in before or after parameters.
When not logged in the following HTML is produced:
When logged in the following HTML is produced: