Make WordPress Core

Ticket #25162: 25162.diff

File 25162.diff, 2.6 KB (added by johnbillion, 10 years ago)
  • src/wp-login.php

     
    840840                        elseif ( is_multisite() && !$user->has_cap('read') )
    841841                                $redirect_to = get_dashboard_url( $user->ID );
    842842                        elseif ( !$user->has_cap('edit_posts') )
    843                                 $redirect_to = admin_url('profile.php');
     843                                $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
    844844                }
    845845                wp_safe_redirect($redirect_to);
    846846                exit();
  • src/wp-includes/admin-bar.php

     
    174174function wp_admin_bar_my_account_item( $wp_admin_bar ) {
    175175        $user_id      = get_current_user_id();
    176176        $current_user = wp_get_current_user();
    177         $profile_url  = get_edit_profile_url( $user_id );
    178177
    179178        if ( ! $user_id )
    180179                return;
    181180
     181        $profile_url = current_user_can( 'read' ) ? get_edit_profile_url( $user_id ) : '#';
     182
    182183        $avatar = get_avatar( $user_id, 26 );
    183184        $howdy  = sprintf( __('Howdy, %1$s'), $current_user->display_name );
    184185        $class  = empty( $avatar ) ? '' : 'with-avatar';
     
    204205function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
    205206        $user_id      = get_current_user_id();
    206207        $current_user = wp_get_current_user();
    207         $profile_url  = get_edit_profile_url( $user_id );
    208208
    209209        if ( ! $user_id )
    210210                return;
    211211
     212        $profile_url = current_user_can( 'read' ) ? get_edit_profile_url( $user_id ) : '#';
     213
    212214        $wp_admin_bar->add_group( array(
    213215                'parent' => 'my-account',
    214216                'id'     => 'user-actions',
     
    229231                        'tabindex' => -1,
    230232                ),
    231233        ) );
    232         $wp_admin_bar->add_menu( array(
    233                 'parent' => 'user-actions',
    234                 'id'     => 'edit-profile',
    235                 'title'  => __( 'Edit My Profile' ),
    236                 'href' => $profile_url,
    237         ) );
     234        if ( current_user_can( 'read' ) ) {
     235                $wp_admin_bar->add_menu( array(
     236                        'parent' => 'user-actions',
     237                        'id'     => 'edit-profile',
     238                        'title'  => __( 'Edit My Profile' ),
     239                        'href'   => $profile_url,
     240                ) );
     241        }
     242
    238243        $wp_admin_bar->add_menu( array(
    239244                'parent' => 'user-actions',
    240245                'id'     => 'logout',
     
    276281        $wp_admin_bar->add_menu( array(
    277282                'id'    => 'site-name',
    278283                'title' => $title,
    279                 'href'  => is_admin() ? home_url( '/' ) : admin_url(),
     284                'href'  => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
    280285        ) );
    281286
    282287        // Create submenu items.
     
    299304                        ) );
    300305                }
    301306
    302         } else {
     307        } else if ( current_user_can( 'read' ) ) {
    303308                // We're on the front end, link to the Dashboard.
    304309                $wp_admin_bar->add_menu( array(
    305310                        'parent' => 'site-name',