Skip to:
Content

bbPress.org

Changeset 4311


Ignore:
Timestamp:
11/03/2012 07:06:20 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Update bbp_map_primary_meta_caps() to block for inactive users, and check cap for active users.
  • See #1939.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/users/capabilities.php

    r4308 r4311  
    5050    // What capability is being checked?
    5151    switch ( $cap ) {
    52 
    53         // Minimum required cap to read any forum content
    54         case 'spectate' :
    55 
    56         // Minimum required cap to create any forum content
     52        case 'spectate'    :
    5753        case 'participate' :
    58 
    59             // Inactive users cannot participate
     54        case 'moderate'    :
     55
     56            // Do not allow inactive users
    6057            if ( bbp_is_user_inactive( $user_id ) ) {
    6158                $caps = array( 'do_not_allow' );
    6259
    6360            // Moderators are always participants
    64             } elseif ( user_can( $user_id, 'moderate' ) ) {
     61            } else {
    6562                $caps = array( $cap );
    66 
    67             // Map to read
    68             } else {
    69                 $caps = array( 'read' );
    70             }
    71 
    72             break;
    73 
    74         case 'moderate' :
    75 
    76             // All admins are moderators
    77             if ( user_can( $user_id, 'administrator' ) ) {
    78                 $caps = array( 'read' );
    7963            }
    8064
     
    259243
    260244    // Bail if not logged in or already a member of this site
    261     if ( ! is_user_logged_in() || current_user_can( 'read' ) )
     245    if ( ! is_user_logged_in() )
     246        return;
     247
     248    // Get the current user ID
     249    $user_id = get_current_user_id();
     250
     251    // Bail if user already has a forums role
     252    if ( bbp_get_user_role( $user_id ) )
    262253        return;
    263254
    264255    // Bail if user is marked as spam or is deleted
    265     if ( bbp_is_user_inactive() )
     256    if ( bbp_is_user_inactive( $user_id ) )
    266257        return;
    267258
Note: See TracChangeset for help on using the changeset viewer.