Skip to:
Content

bbPress.org

Changeset 4179


Ignore:
Timestamp:
08/29/2012 04:30:07 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Add 'participate' capability to admin role defaults.
  • Rearrange bbp_global_access_role_mask() to check logged in and member of blog before inactive.
  • Default to WordPress Subscriber role in bbp_global_access_role_mask().
  • Addresses issue where users don't get proper default caps masked to them.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-caps.php

    r4173 r4179  
    632632                // Administrator
    633633                case 'administrator' :
    634 
    635634                        $caps = array(
     635
     636                                // General caps
     637                                'participate',
     638                                'moderate',
     639                                'throttle',
     640                                'view_trash',
    636641
    637642                                // Forum caps
    … …  
    664669                                'edit_topic_tags',
    665670                                'delete_topic_tags',
    666                                 'assign_topic_tags',
    667 
    668                                 // Misc
    669                                 'moderate',
    670                                 'throttle',
    671                                 'view_trash'
     671                                'assign_topic_tags'
    672672                        );
    673673
    … …  
    763763                return;
    764764
     765        // Bail if not logged in or already a member of this site
     766        if ( ! is_user_logged_in() || is_user_member_of_blog() )
     767                return;
     768
    765769        // Bail if user is marked as spam or is deleted
    766770        if ( bbp_is_user_inactive() )
    767771                return;
    768772
    769         // Normal user is logged in but not a member of this site
    770         if ( is_user_logged_in() && ! is_user_member_of_blog() ) {
    771 
    772                 // Assign user the default role to map caps to
    773                 $default_role  = get_option( 'default_role' );
    774 
    775                 // Get bbPress caps for the default role
    776                 $caps_for_role = bbp_get_caps_for_role( $default_role );
    777 
    778                 // Set all caps to true
    779                 foreach ( $caps_for_role as $cap ) {
    780                         $mapped_meta_caps[$cap] = true;
    781                 }
    782 
    783                 // Add 'read' cap just in case
    784                 $mapped_meta_caps['read']       = true;
    785                 $mapped_meta_caps['bbp_masked'] = true;
    786 
    787                 // Allow global access caps to be manipulated
    788                 $mapped_meta_caps = apply_filters( 'bbp_global_access_mapped_meta_caps', $mapped_meta_caps );
    789 
    790                 // Assign the role and mapped caps to the current user
    791                 $bbp = bbpress();
    792                 $bbp->current_user->roles[0] = $default_role;
    793                 $bbp->current_user->caps     = $mapped_meta_caps;
    794                 $bbp->current_user->allcaps  = $mapped_meta_caps;
    795         }
     773        // Assign user the default role to map caps to
     774        $default_role  = get_option( 'default_role', 'subscriber' );
     775
     776        // Get bbPress caps for the default role
     777        $caps_for_role = bbp_get_caps_for_role( $default_role );
     778
     779        // Set all caps to true
     780        foreach ( $caps_for_role as $cap )
     781                $default_caps[$cap] = true;
     782
     783        // Add 'read' cap just in case
     784        $default_caps['read']       = true;
     785        $default_caps['bbp_masked'] = true;
     786
     787        // Allow global access caps to be manipulated
     788        $default_caps = apply_filters( 'bbp_global_access_default_caps', $default_caps );
     789
     790        // Assign the role and mapped caps to the current user
     791        $bbp = bbpress();
     792        $bbp->current_user->roles[0] = $default_role;
     793        $bbp->current_user->caps     = $default_caps;
     794        $bbp->current_user->allcaps  = $default_caps;
    796795}
    797796
Note: See TracChangeset for help on using the changeset viewer.