Make WordPress Core


Ignore:
Timestamp:
07/11/2005 10:39:50 PM (19 years ago)
Author:
ryan
Message:

Role/capability system. Round one. Props: Owen Winkler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-functions.php

    r2702 r2703  
    227227        if ( !empty( $user->user_nickname ) )
    228228            update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
    229         if ( !empty( $user->user_level ) )
     229        if ( !empty( $user->user_level ) ) {
    230230            update_usermeta( $user->ID, $table_prefix . 'user_level', $user->user_level );
     231            $role = translate_level_to_role($user->user_level);
     232            update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) );
     233        }
    231234        if ( !empty( $user->user_icq ) )
    232235            update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
     
    750753    return $template;
    751754}
     755
     756function translate_level_to_role($level) {
     757    switch ($level) {
     758    case 10:
     759    case 9:
     760    case 8:
     761        return 'publisher';
     762    case 7:
     763    case 6:
     764    case 5:
     765        return 'managing_editor';
     766    case 4:
     767    case 3:
     768        return 'copy_editor';
     769    case 2:
     770        return 'staff_writer';
     771    case 1:
     772        return 'freelancer';
     773    case 0:
     774        return 'visitor';
     775    }
     776}
     777
    752778?>
Note: See TracChangeset for help on using the changeset viewer.