wp_register()
Displays either the link to the dashboard ("Site Admin") if the user is logged in or "Register" link if the user is not logged in.
The "Register" link is not offered if the Administration > Settings > General > Membership: Anyone can register box is not checked.
Uses: wp_registration_url(), admin_url()
1 time — 0.000127 sec (fast) | 50000 times — 3.03 sec (fast)
Hooks from the function
Return
null|String
. Void if $display argument is true, registration or admin link if $display is false.
Usage
wp_register( $before, $after, $display );
- $before(string)
- Text to output before the link.
Default: <li> - $after(string)
- Text to output after the link.
Default: </li> - $display(true|false)
- Default to echo and not return the link.
Default: true
Examples
#1 Display a link to the admin panel or registration page
The link will be wrapped in <li> tag:
wp_register(); /* output: <li> <a href="/wp-admin/">Site Admin</a> </li> */
#2 Without "before" and "after" text
This example will output a link without a wrapping <li> tag:
<?php wp_register('', ''); ?>
In the result, we will get this link if not logged in:
<a href="http://example.com/wp-login.php?action=register">Register</a>
Or this one if logged in:
<a href="http://example.com/wp-admin/">Site Admin</a>
Changelog
Since 1.5.0 | Introduced. |