wp_register

The timeline below displays how wordpress function wp_register has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Displays 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.
 *
 * @since 1.5.0
 *
 * @param string $before  Text to output before the link. Default `<li>`.
 * @param string $after   Text to output after the link. Default `</li>`.
 * @param bool   $display Default to echo and not return the link.
 * @return void|string Void if `$display` argument is true, registration or admin link
 *                     if `$display` is false.
 */
function wp_register($before = '<li>', $after = '</li>', $display = 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 ($display) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 6.1

/**
 * Displays 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after  Text to output after the link. Default `</li>`.
 * @param bool   $echo   Default to echo and not return the link.
 * @return void|string Void if `$echo` argument is true, registration or admin link
 *                     if `$echo` is false.
 */
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;
    }
}

WordPress Version: 5.4

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after  Text to output after the link. Default `</li>`.
 * @param bool   $echo   Default to echo and not return the link.
 * @return void|string Void if `$echo` argument is true, registration or admin link
 *                     if `$echo` is false.
 */
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;
    }
}

WordPress Version: 4.6

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after  Text to output after the link. Default `</li>`.
 * @param bool   $echo   Default to echo and not return the link.
 * @return string|void String when retrieving.
 */
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;
    }
}

WordPress Version: 4.4

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after  Text to output after the link. Default `</li>`.
 * @param bool   $echo   Default to echo and not return the link.
 * @return string|void String when retrieving.
 */
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 = '';
    }
    /**
     * Filter 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;
    }
}

WordPress Version: 4.3

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after  Text to output after the link. Default `</li>`.
 * @param bool   $echo   Default to echo and not return the link.
 * @return string|void String when retrieving.
 */
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 = '';
        }
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }
    /**
     * Filter 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;
    }
}

WordPress Version: 4.1

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link. Default `<li>`.
 * @param string $after Text to output after the link. Default `</li>`.
 * @param boolean $echo Default to echo and not return the link.
 * @return string|null String when retrieving, null when displaying.
 */
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 = '';
        }
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }
    /**
     * Filter 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;
    }
}

WordPress Version: 4.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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link (defaults to <li>).
 * @param string $after Text to output after the link (defaults to </li>).
 * @param boolean $echo Default to echo and not return the link.
 * @return string|null String when retrieving, null when displaying.
 */
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 = '';
        }
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }
    /**
     * Filter 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;
    }
}

WordPress Version: 3.9

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $before Text to output before the link (defaults to <li>).
 * @param string $after Text to output after the link (defaults to </li>).
 * @param boolean $echo Default to echo and not return the link.
 * @return string|null String when retrieving, null when displaying.
 */
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 = '';
        }
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }
    if ($echo) {
        /**
         * Filter 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.
         */
        echo apply_filters('register', $link);
    } else {
        /** This filter is documented in wp-includes/general-template.php */
        return apply_filters('register', $link);
    }
}

WordPress Version: 3.7

/**
 * 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.
 *
 * @since 1.5.0
 * @uses apply_filters() Calls 'register' hook on register / admin link content.
 *
 * @param string $before Text to output before the link (defaults to <li>).
 * @param string $after Text to output after the link (defaults to </li>).
 * @param boolean $echo Default to echo and not return the link.
 * @return string|null String when retrieving, null when displaying.
 */
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 = '';
        }
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }
    if ($echo) {
        echo apply_filters('register', $link);
    } else {
        return apply_filters('register', $link);
    }
}