mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Show access denied page and list a user's sites if they visit an admin they don't have permissions for rather than redirecting to the users' primary blog. fixes #17121
git-svn-id: http://svn.automattic.com/wordpress/trunk@17762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
372e5fd8de
commit
06c03f44f0
@ -496,26 +496,41 @@ function sync_category_tag_slugs( $term, $taxonomy ) {
|
|||||||
}
|
}
|
||||||
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
|
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
|
||||||
|
|
||||||
function redirect_user_to_blog() {
|
function _access_denied_splash() {
|
||||||
$c = 0;
|
if ( ! is_user_logged_in() )
|
||||||
if ( isset( $_GET['c'] ) )
|
return;
|
||||||
$c = (int) $_GET['c'];
|
|
||||||
|
|
||||||
if ( $c >= 5 ) {
|
$blogs = get_blogs_of_user( get_current_user_id() );
|
||||||
wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) );
|
|
||||||
}
|
|
||||||
$c ++;
|
|
||||||
|
|
||||||
$blog = get_active_blog_for_user( get_current_user_id() );
|
$blog_name = get_bloginfo( 'name' );
|
||||||
|
|
||||||
if ( is_object( $blog ) ) {
|
if ( empty( $blogs ) ) {
|
||||||
wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
|
wp_die( sprintf( __( 'You attempted to access the "%s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "Test" dashboard, please contact your network administrator.' ), $blog_name ) );
|
||||||
} else {
|
|
||||||
wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
|
|
||||||
}
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
|
|
||||||
|
$output = '<p>' . sprintf( __( 'You attempted to access the "%s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "Test" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
|
||||||
|
$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
|
||||||
|
|
||||||
|
$output .= '<h3>' . __('Your Sites') . '</h3>';
|
||||||
|
$output .= '<table>';
|
||||||
|
|
||||||
|
foreach ( $blogs as $blog ) {
|
||||||
|
$output .= "<tr>";
|
||||||
|
$output .= "<td valign='top'>";
|
||||||
|
$output .= "{$blog->blogname}";
|
||||||
|
$output .= "</td>";
|
||||||
|
$output .= "<td valign='top'>";
|
||||||
|
$output .= "<a href='" . esc_url( get_admin_url( $blog->userblog_id ) ) . "'>" . __( 'Visit Dashboard' ) . "</a> | <a href='" . esc_url( get_home_url( $blog->userblog_id ) ). "'>" . __( 'View Site' ) . "</a>" ;
|
||||||
|
$output .= "</td>";
|
||||||
|
$output .= "</tr>";
|
||||||
|
}
|
||||||
|
$output .= '</table>';
|
||||||
|
|
||||||
|
wp_die( $output );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
|
||||||
|
|
||||||
function check_import_new_users( $permission ) {
|
function check_import_new_users( $permission ) {
|
||||||
if ( !is_super_admin() )
|
if ( !is_super_admin() )
|
||||||
|
Loading…
Reference in New Issue
Block a user