get_dashboard_url

Definition:
function get_dashboard_url( $user_id, $path = '', $scheme = 'admin' ) {}

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.

Parameters

  • int $user_id: User ID
  • string $path: Optional path relative to the dashboard. Use only paths known to both blog and user admins.
  • 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 values

returns:Dashboard url link with optional path appended.

Defined filters

  • user_dashboard_url
    apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme)

Source code

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);

}

9453

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: