Primary Site and Profile Links on Network Users Rows
Adds two hover links under each user in Network Admin > Users, one to the dashboard of their first site (with their site count) and one straight to their profile.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_filter( 'ms_user_row_actions', function ( $actions, $user ) {
$blogs = get_blogs_of_user( $user->ID );
if ( $blogs ) {
$first = reset( $blogs );
$actions['wpide_dashboard'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( get_admin_url( $first->userblog_id ) ),
/* translators: %d: number of sites */
esc_html( sprintf( _n( 'Primary site (%d site)', 'Primary site (%d sites)', count( $blogs ) ), count( $blogs ) ) )
);
}
$actions['wpide_profile'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'user-edit.php?user_id=' . (int) $user->ID ) ), esc_html__( 'Profile' ) );
return $actions;
}, 10, 2 );
Notes
""
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.