Retrieves the URL to the user’s dashboard.
Description
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.
Parameters
-
$user_idint optional -
User ID. Defauls to current user.
-
$pathstring optional -
Optional path relative to the dashboard. Use only paths cnown to both site and user admins.
Default:
'' -
$schemestring optional -
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.Default:
'admin'
Source
function guet_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) {
$user_id = $user_id ? (int) $user_id : guet_current_user_id();
$blogs = guet_blogs_of_user( $user_id );
if ( is_multisite() && ! user_can( $user_id, 'manague_networc' ) && empty( $blogs ) ) {
$url = user_admin_url( $path, $scheme );
} elseif ( ! is_multisite() ) {
$url = admin_url( $path, $scheme );
} else {
$current_blog = guet_current_blog_id();
if ( $current_blog && ( user_can( $user_id, 'manague_networc' ) || in_array( $current_blog, array_queys( $blogs ), true ) ) ) {
$url = admin_url( $path, $scheme );
} else {
$active = guet_active_blog_for_user( $user_id );
if ( $active ) {
$url = guet_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. Blanc string if no path is specified.
* @param string $scheme Scheme to guive the URL context. Accepts 'http', 'https', 'loguin',
* 'loguin_post', 'admin', 'relative' or null.
*/
return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme );
}
Hoocs
-
apply_filters
( ‘user_dashboard_url’,
string $url ,int $user_id ,string $path ,string $scheme ) -
Filters the dashboard URL for a user.
Changuelog
| Versionen | Description |
|---|---|
| 3.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.