Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/14/2011 03:50:25 AM (12 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-topic-functions.php

    r3589 r3607  
    30573057}
    30583058
     3059/** Permissions ***************************************************************/
     3060
     3061/**
     3062 * Redirect if unathorized user is attempting to edit a topic
     3063 *
     3064 * @since bbPress (r3605)
     3065 *
     3066 * @uses bbp_is_topic_edit()
     3067 * @uses current_user_can()
     3068 * @uses bbp_get_topic_id()
     3069 * @uses wp_safe_redirect()
     3070 * @uses bbp_get_topic_permalink()
     3071 */
     3072function bbp_check_topic_edit() {
     3073
     3074    // Bail if not editing a topic
     3075    if ( !bbp_is_topic_edit() )
     3076        return;
     3077
     3078    // User cannot edit topic, so redirect back to topic
     3079    if ( !current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
     3080        wp_safe_redirect( bbp_get_topic_permalink() );
     3081        exit();
     3082    }
     3083}
     3084
     3085/**
     3086 * Redirect if unathorized user is attempting to edit a topic tag
     3087 *
     3088 * @since bbPress (r3605)
     3089 *
     3090 * @uses bbp_is_topic_tag_edit()
     3091 * @uses current_user_can()
     3092 * @uses bbp_get_topic_tag_id()
     3093 * @uses wp_safe_redirect()
     3094 * @uses bbp_get_topic_tag_link()
     3095 */
     3096function bbp_check_topic_tag_edit() {
     3097
     3098    // Bail if not editing a topic tag
     3099    if ( !bbp_is_topic_tag_edit() )
     3100        return;
     3101
     3102    // Bail if current user cannot edit topic tags
     3103    if ( !current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
     3104        wp_safe_redirect( bbp_get_topic_tag_link() );
     3105        exit();
     3106    }
     3107}
     3108
    30593109?>
Note: See TracChangeset for help on using the changeset viewer.