Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/14/2011 03:50:25 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_template_redirect() and use for checking various edit screens:

  • Introduce bbp_check_forum_edit() to check for forum edit
  • Introduce bbp_check_topic_edit() to check for topic edit
  • Introduce bbp_check_reply_edit() to check for reply edit
  • Introduce bbp_check_topic_tag_edit() to check for topic tag edit
  • Introduce bbp_check_user_edit() to check for user edit
  • Remove these checks from bbp_pre_get_posts() and only use it to setup query vars
  • Fixes #1684, r3605
  • For 2.1 (plugin) branch
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3589 r3607  
    11471147}
    11481148
     1149/** Permissions ***************************************************************/
     1150
     1151/**
     1152 * Redirect if unathorized user is attempting to edit a forum
     1153 *
     1154 * @since bbPress (r3607)
     1155 *
     1156 * @uses bbp_is_forum_edit()
     1157 * @uses current_user_can()
     1158 * @uses bbp_get_forum_id()
     1159 * @uses wp_safe_redirect()
     1160 * @uses bbp_get_forum_permalink()
     1161 */
     1162function bbp_check_forum_edit() {
     1163
     1164    // Bail if not editing a topic
     1165    if ( !bbp_is_forum_edit() )
     1166        return;
     1167
     1168    // User cannot edit topic, so redirect back to reply
     1169    if ( !current_user_can( 'edit_forum', bbp_get_forum_id() ) ) {
     1170        wp_safe_redirect( bbp_get_forum_permalink() );
     1171        exit();
     1172    }
     1173}
     1174
    11491175?>
Note: See TracChangeset for help on using the changeset viewer.