Skip to:
Content

bbPress.org


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

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

  • 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
  • See #1684
  • For 2.0 branch
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/bbp-includes/bbp-topic-functions.php

    r3545 r3605  
    30423042}
    30433043
     3044/** Permissions ***************************************************************/
     3045
     3046/**
     3047 * Redirect if unathorized user is attempting to edit a topic
     3048 *
     3049 * @since bbPress (r3605)
     3050 *
     3051 * @uses bbp_is_topic_edit()
     3052 * @uses current_user_can()
     3053 * @uses bbp_get_topic_id()
     3054 * @uses wp_safe_redirect()
     3055 * @uses bbp_get_topic_permalink()
     3056 */
     3057function bbp_check_topic_edit() {
     3058
     3059    // Bail if not editing a topic
     3060    if ( !bbp_is_topic_edit() )
     3061        return;
     3062
     3063    // User cannot edit topic, so redirect back to topic
     3064    if ( !current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
     3065        wp_safe_redirect( bbp_get_topic_permalink() );
     3066        exit();
     3067    }
     3068}
     3069
     3070/**
     3071 * Redirect if unathorized user is attempting to edit a topic tag
     3072 *
     3073 * @since bbPress (r3605)
     3074 *
     3075 * @uses bbp_is_topic_tag_edit()
     3076 * @uses current_user_can()
     3077 * @uses bbp_get_topic_tag_id()
     3078 * @uses wp_safe_redirect()
     3079 * @uses bbp_get_topic_tag_link()
     3080 */
     3081function bbp_check_topic_tag_edit() {
     3082
     3083    // Bail if not editing a topic tag
     3084    if ( !bbp_is_topic_tag_edit() )
     3085        return;
     3086
     3087    // Bail if current user cannot edit topic tags
     3088    if ( !current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
     3089        wp_safe_redirect( bbp_get_topic_tag_link() );
     3090        exit();
     3091    }
     3092}
     3093
    30443094?>
Note: See TracChangeset for help on using the changeset viewer.