Skip to:
Content

bbPress.org

Changeset 4316


Ignore:
Timestamp:
11/03/2012 08:00:14 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Enforce blocked logged in users by showing them a 404 if they cannot spectate.
  • See #1939.
Location:
trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/core/actions.php

    r4303 r4316  
    246246 * 3. Editing forums, topics, replies, users, and tags
    247247 */
     248add_action( 'bbp_template_redirect', 'bbp_forum_enforce_blocked',   -1 );
    248249add_action( 'bbp_template_redirect', 'bbp_forum_enforce_hidden',    -1 );
    249250add_action( 'bbp_template_redirect', 'bbp_forum_enforce_private',   -1 );
  • trunk/includes/users/functions.php

    r4298 r4316  
    14861486}
    14871487
     1488/**
     1489 * Check if a user is blocked, or cannot spectate the forums.
     1490 *
     1491 * @since bbPress (r2996)
     1492 *
     1493 * @uses is_user_logged_in() To check if user is logged in
     1494 * @uses is_super_admin() To check if user is a super admin
     1495 * @uses current_user_can() To check if the current user can spectate
     1496 * @uses is_bbpress() To check if in a bbPress section of the site
     1497 * @uses bbp_set_404() To set a 404 status
     1498 */
     1499function bbp_forum_enforce_blocked() {
     1500
     1501    // Bail if not logged in or super admin
     1502    if ( ! is_user_logged_in() || is_super_admin() ) {
     1503        return;
     1504    }
     1505
     1506    // Set 404 if in bbPress and user cannot spectate
     1507    if ( is_bbpress() && ! current_user_can( 'spectate' ) ) {
     1508        bbp_set_404();
     1509    }
     1510}
     1511
    14881512/** Converter *****************************************************************/
    14891513
Note: See TracChangeset for help on using the changeset viewer.