get_dashboard_url

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

WordPress Version: 5.5

/**
 * Retrieves the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user
 * belongs to the current site, the dashboard for the current site is returned. If the user
 * cannot edit the current site, the dashboard to the user's primary site is returned.
 *
 * @since 3.1.0
 *
 * @param int    $user_id Optional. User ID. Defaults to current user.
 * @param string $path    Optional path relative to the dashboard. Use only paths known to
 *                        both site and user admins. Default empty.
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin()
 *                        and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard URL link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (is_multisite() && !user_can($user_id, 'manage_network') && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (user_can($user_id, 'manage_network') || in_array($current_blog, array_keys($blogs), true))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filters the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 4.8

/**
 * Retrieves the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user
 * belongs to the current site, the dashboard for the current site is returned. If the user
 * cannot edit the current site, the dashboard to the user's primary site is returned.
 *
 * @since 3.1.0
 *
 * @param int    $user_id Optional. User ID. Defaults to current user.
 * @param string $path    Optional path relative to the dashboard. Use only paths known to
 *                        both site and user admins. Default empty.
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin()
 *                        and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard URL link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (is_multisite() && !user_can($user_id, 'manage_network') && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (user_can($user_id, 'manage_network') || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filters the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 4.6

/**
 * Retrieves the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user
 * belongs to the current site, the dashboard for the current site is returned. If the user
 * cannot edit the current site, the dashboard to the user's primary site is returned.
 *
 * @since 3.1.0
 *
 * @param int    $user_id Optional. User ID. Defaults to current user.
 * @param string $path    Optional path relative to the dashboard. Use only paths known to
 *                        both site and user admins. Default empty.
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin()
 *                        and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard URL link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (!is_super_admin() && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filters the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 4.5

/**
 * Get the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
 * the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
 * primary site is returned.
 *
 * @since 3.1.0
 *
 * @param int    $user_id Optional. User ID. Defaults to current user.
 * @param string $path    Optional path relative to the dashboard. Use only paths known to both site and user admins.
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard url link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (!is_super_admin() && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filter the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 4.3

/**
 * Get the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
 * the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
 * primary blog is returned.
 *
 * @since 3.1.0
 *
 * @param int    $user_id Optional. User ID. Defaults to current user.
 * @param string $path    Optional path relative to the dashboard. Use only paths known to both blog and user admins.
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard url link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (!is_super_admin() && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filter the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 3.9

/**
 * Get the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
 * the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
 * primary blog is returned.
 *
 * @since 3.1.0
 *
 * @param int $user_id Optional. User ID. Defaults to current user.
 * @param string $path Optional path relative to the dashboard. Use only paths known to both blog and user admins.
 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard url link with optional path appended.
 */
function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin')
{
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $blogs = get_blogs_of_user($user_id);
    if (!is_super_admin() && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    /**
     * Filter the dashboard URL for a user.
     *
     * @since 3.1.0
     *
     * @param string $url     The complete URL including scheme and path.
     * @param int    $user_id The user ID.
     * @param string $path    Path relative to the URL. Blank string if no path is specified.
     * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
     *                        'login_post', 'admin', 'relative' or null.
     */
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}

WordPress Version: 3.7

/**
 * Get the URL to the user's dashboard.
 *
 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
 * the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
 * primary blog is returned.
 *
 * @since 3.1.0
 *
 * @param int $user_id User ID
 * @param string $path Optional path relative to the dashboard. Use only paths known to both blog and user admins.
 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
 * @return string Dashboard url link with optional path appended.
 */
function get_dashboard_url($user_id, $path = '', $scheme = 'admin')
{
    $user_id = (int) $user_id;
    $blogs = get_blogs_of_user($user_id);
    if (!is_super_admin() && empty($blogs)) {
        $url = user_admin_url($path, $scheme);
    } elseif (!is_multisite()) {
        $url = admin_url($path, $scheme);
    } else {
        $current_blog = get_current_blog_id();
        if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) {
            $url = admin_url($path, $scheme);
        } else {
            $active = get_active_blog_for_user($user_id);
            if ($active) {
                $url = get_admin_url($active->blog_id, $path, $scheme);
            } else {
                $url = user_admin_url($path, $scheme);
            }
        }
    }
    return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme);
}