function pg_has_topics($args = '') { //check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see) if ($args['post__in']) { return $args; } $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any'; if ($default_post_parent == 'any') { if (bbp_is_user_keymaster()) { return $args; } $user_id = wp_get_current_user()->ID; if (user_can($user_id, 'moderate')) { $check = get_user_meta($user_id, 'private_group', true); if ($check == '') { return $args; } } global $wpdb; $topic = bbp_get_topic_post_type(); $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics $allowed_posts = check_private_groups_topic_ids($post_ids); $args['post__in'] = $allowed_posts; } return $args; }
function pg_get_user_replies_created($user_id = 0) { // Validate user $user_id2 = bbp_get_user_id($user_id); $current_user = wp_get_current_user()->ID; if (empty($user_id)) { return false; } if (bbp_is_user_keymaster()) { $limit = 'n'; } if (user_can($current_user, 'moderate')) { $check = get_user_meta($current_user, 'private_group', true); if ($check == '') { $limit = 'n'; } } if ($limit != 'n') { global $wpdb; $reply = bbp_get_reply_post_type(); $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$reply}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics $allowed_posts = check_private_groups_reply_ids($post_ids); } // The default reply query with allowed topic and reply ids array added // Try to get the topics $query = bbp_has_replies(array('post_type' => bbp_get_reply_post_type(), 'order' => 'DESC', 'author' => $user_id2, 'post__in' => $allowed_posts)); return apply_filters('pg_get_user_replies_created', $query, $user_id); }
static function wp_init() { if (bbp_is_user_keymaster()) { return; } add_filter('bbp_allow_anonymous', array(__CLASS__, 'allow_anonymous')); add_filter('bbp_current_user_can_publish_replies', array(__CLASS__, 'publish_replies')); add_filter('bbp_current_user_can_access_create_reply_form', array(__CLASS__, 'publish_replies')); add_filter('bbp_current_user_can_publish_topics', array(__CLASS__, 'publish_topics')); add_filter('bbp_current_user_can_access_create_topic_form', array(__CLASS__, 'publish_topics')); add_filter('bbp_before_user_can_view_forum_parse_args', array(__CLASS__, 'view_forum_args')); add_filter('bbp_user_can_view_forum', array(__CLASS__, 'view_forum'), 10, 3); add_filter('bbp_is_forum_private', array(__CLASS__, 'bbp_is_forum_private'), 10, 3); add_filter('bbp_template_include_theme_compat', array(__CLASS__, 'template_no_access')); // 업로드 권한 체크는 Attachments 에서(attachments.php) // add_action( 'pre_get_posts', array( __CLASS__, 'include_private_forums' ), 5 ); }
/** * Check if the user is allowed to view the content (forum/topic/post) * Show a 404 error if the user does not have a permission to access the content */ function tehnik_bpp_enforce_permissions() { // Bail if not viewing a bbPress item if (!is_bbpress()) { return; } // Bail if not viewing a single item or if user has caps if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_hidden_forums')) { return; } if (!tehnik_bpp_can_user_view_post()) { if (!is_user_logged_in()) { auth_redirect(); } else { bbp_set_404(); } } }
function private_groups_can_user_view_post($user_id, $forum_id = '') { //the $forum_id that needs to be passed to this function is the forum_id that the post belongs to /* Assume the user can view the post at this point. */ $can_view = true; /* Get the groups for the forum */ $groups = get_post_meta($forum_id, '_private_group', false); /* If we have groups set for this forum let's get to work. */ if (!empty($groups) && is_array($groups)) { /** * Since specific groups exist let's assume the user can't view the post at * this point. The rest of this functionality should try to disprove this. */ $can_view = false; /* If the user's not logged in, assume it's blocked at this point. */ if (!is_user_logged_in()) { $can_view = false; } /*Check if user is keymaster*/ if (bbp_is_user_keymaster()) { $can_view = true; } else { $role = bbp_get_user_role($user_id); $check = get_user_meta($user_id, 'private_group', true); //if they are a mod, and they have no forum groups set, then they can moderate and see across all forums if ($role == 'bbp_moderator' && empty($check)) { $can_view = true; } else { /* Loop through each group and set $can_view to true if the user has this group. */ $check = get_user_meta($user_id, 'private_group', true); foreach ($groups as $group) { if ($check == $group) { $can_view = true; } } } } } /* Allow developers to overwrite the final return value. */ return apply_filters('private_groups_can_user_view_post', $can_view, $user_id, $forum_id); }
/** * Does a user have a profile for the current site * * @since bbPress (r4362) * * @param int $user_id User ID to check * @param int $blog_id Blog ID to check * * @uses bbp_get_user_id() To verify the user ID * @uses get_userdata() To get the user's data * @uses bbp_is_user_keymaster() To determine if user can see inactive users * @uses bbp_is_user_inactive() To check if user is spammer or deleted * @uses apply_filters() To allow override of this functions result * * @return boolean Whether or not the user has a profile on this blog_id */ function bbp_user_has_profile($user_id = 0) { // Assume every user has a profile $retval = true; // Validate user ID, default to displayed or current user $user_id = bbp_get_user_id($user_id, true, true); // Try to get this user's data $user = get_userdata($user_id); // No user found, return false if (empty($user)) { $retval = false; // User is inactive, and current user is not a keymaster } elseif (!bbp_is_user_keymaster() && bbp_is_user_inactive($user->ID)) { $retval = false; } // Filter and return return (bool) apply_filters('bbp_show_user_profile', $retval, $user_id); }
/** * Add post date, author post count and author ip to the author element. */ public function add_author_post_date_count_ip() { ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(bbp_get_reply_id()); ?> </div> <div class="bbps-post-count"><?php printf(__('Post count: %s', 'Avada'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id()) + bbp_get_user_topic_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_topic_author_admin_details'); ?> <div class="bbp-reply-ip fusion-reply-id"><?php bbp_author_ip(bbp_get_topic_id()); ?> </div> <?php do_action('bbp_theme_after_topic_author_admin_details'); ?> <?php } }
/** * Checks topics and replies against the discussion blacklist of blocked keys * * @since 2.0.0 bbPress (r3446) * * @param array $anonymous_data Anonymous user data * @param int $author_id Topic or reply author ID * @param string $title The title of the content * @param string $content The content being posted * @uses bbp_is_user_keymaster() Allow keymasters to bypass blacklist * @uses bbp_current_author_ip() To get current user IP address * @uses bbp_current_author_ua() To get current user agent * @return bool True if test is passed, false if fail */ function bbp_check_for_blacklist($anonymous_data = false, $author_id = 0, $title = '', $content = '') { // Allow for blacklist check to be skipped if (apply_filters('bbp_bypass_check_for_blacklist', false, $anonymous_data, $author_id, $title, $content)) { return true; } // Bail if keymaster is author if (!empty($author_id) && bbp_is_user_keymaster($author_id)) { return true; } /** Blacklist *************************************************************/ /** * Filters the bbPress blacklist keys. * * @since 2.6.0 bbPress (r6050) * * @param string $blacklist List of blacklist keys. One per new line. */ $blacklist = apply_filters('bbp_blacklist_keys', trim(get_option('blacklist_keys'))); // Bail if blacklist is empty if (empty($blacklist)) { return true; } /** User Data *************************************************************/ // Define local variable $_post = array(); // Map anonymous user data if (!empty($anonymous_data)) { $_post['author'] = $anonymous_data['bbp_anonymous_name']; $_post['email'] = $anonymous_data['bbp_anonymous_email']; $_post['url'] = $anonymous_data['bbp_anonymous_website']; // Map current user data } elseif (!empty($author_id)) { // Get author data $user = get_userdata($author_id); // If data exists, map it if (!empty($user)) { $_post['author'] = $user->display_name; $_post['email'] = $user->user_email; $_post['url'] = $user->user_url; } } // Current user IP and user agent $_post['user_ip'] = bbp_current_author_ip(); $_post['user_ua'] = bbp_current_author_ua(); // Post title and content $_post['title'] = $title; $_post['content'] = $content; // Ensure HTML tags are not being used to bypass the blacklist. $_post['comment_without_html'] = wp_strip_all_tags($content); /** Words *****************************************************************/ // Get words separated by new lines $words = explode("\n", $blacklist); // Loop through words foreach ((array) $words as $word) { // Trim the whitespace from the word $word = trim($word); // Skip empty lines if (empty($word)) { continue; } // Do some escaping magic so that '#' chars in the // spam words don't break things: $word = preg_quote($word, '#'); $pattern = "#{$word}#i"; // Loop through post data foreach ($_post as $post_data) { // Check each user data for current word if (preg_match($pattern, $post_data)) { // Post does not pass return false; } } } // Check passed successfully return true; }
/** * Return subforums of given forum * * @since bbPress (r2747) * * @param mixed $args All the arguments supported by {@link WP_Query} * @uses bbp_get_forum_id() To get the forum id * @uses current_user_can() To check if the current user is capable of * reading private forums * @uses get_posts() To get the subforums * @uses apply_filters() Calls 'bbp_forum_get_subforums' with the subforums * and the args * @return mixed false if none, array of subs if yes */ function bbp_forum_get_subforums($args = '') { // Use passed integer as post_parent if (is_numeric($args)) { $args = array('post_parent' => $args); } // Setup possible post__not_in array $post_stati[] = bbp_get_public_status_id(); // Super admin get whitelisted post statuses if (bbp_is_user_keymaster()) { $post_stati = array(bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id()); // Not a keymaster, so check caps } else { // Check if user can read private forums if (current_user_can('read_private_forums')) { $post_stati[] = bbp_get_private_status_id(); } // Check if user can read hidden forums if (current_user_can('read_hidden_forums')) { $post_stati[] = bbp_get_hidden_status_id(); } } // Parse arguments against default values $r = bbp_parse_args($args, array('post_parent' => 0, 'post_type' => bbp_get_forum_post_type(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order title', 'order' => 'ASC', 'ignore_sticky_posts' => true, 'no_found_rows' => true), 'forum_get_subforums'); $r['post_parent'] = bbp_get_forum_id($r['post_parent']); // Create a new query for the subforums $get_posts = new WP_Query(); // No forum passed $sub_forums = !empty($r['post_parent']) ? $get_posts->query($r) : array(); return (array) apply_filters('bbp_forum_get_subforums', $sub_forums, $r); }
/** * Performs a series of checks to ensure the current user can create replies. * * @since 2.0.0 bbPress (r3127) * * @uses bbp_is_user_keymaster() * @uses bbp_is_topic_edit() * @uses current_user_can() * @uses bbp_get_topic_id() * @uses bbp_allow_anonymous() * @uses is_user_logged_in() * * @return bool */ function bbp_current_user_can_access_create_reply_form() { // Users need to earn access $retval = false; // Always allow keymasters if (bbp_is_user_keymaster()) { $retval = true; // Looking at a single topic, topic is open, and forum is open } elseif ((bbp_is_single_topic() || is_page() || is_single()) && bbp_is_topic_open() && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_replies(); // User can edit this topic } elseif (bbp_is_reply_edit()) { $retval = current_user_can('edit_reply', bbp_get_reply_id()); } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_create_reply_form', (bool) $retval); }
/** * Handle the processing and feedback of the admin tools page * * @since 2.0.0 bbPress (r2613) * * @uses check_admin_referer() To verify the nonce and the referer * @uses wp_cache_flush() To flush the cache * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses bbp_get_reply_post_type() To get the reply post type */ function bbp_admin_reset_handler() { // Bail if not resetting if (!bbp_is_post_request() || empty($_POST['bbpress-are-you-sure'])) { return; } // Only keymasters can proceed if (!bbp_is_user_keymaster()) { return; } check_admin_referer('bbpress-reset'); // Stores messages $messages = array(); $failed = __('Failed!', 'bbpress'); $success = __('Success!', 'bbpress'); // Flush the cache; things are about to get ugly. wp_cache_flush(); /** Posts *****************************************************************/ // Post types and status $fpt = bbp_get_forum_post_type(); $tpt = bbp_get_topic_post_type(); $rpt = bbp_get_reply_post_type(); // Define variables $bbp_db = bbp_db(); $statement = __('Deleting Posts… %s', 'bbpress'); $sql_posts = $bbp_db->get_results("SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')", OBJECT_K); $sql_delete = "DELETE FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); /** Post Meta *************************************************************/ if (!empty($sql_posts)) { $sql_meta = array(); foreach ($sql_posts as $key => $value) { $sql_meta[] = $key; } $statement = __('Deleting Post Meta… %s', 'bbpress'); $sql_meta = implode("', '", $sql_meta); $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}');"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); } /** Forum moderators ******************************************************/ $statement = __('Deleting Forum Moderators… %s', 'bbpress'); $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'forum-mod';"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); /** Topic Tags ************************************************************/ $statement = __('Deleting Topic Tags… %s', 'bbpress'); $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag';"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); /** User ******************************************************************/ // First, if we're deleting previously imported users, delete them now if (!empty($_POST['bbpress-delete-imported-users'])) { $sql_users = $bbp_db->get_results("SELECT `user_id` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '_bbp_user_id'", OBJECT_K); if (!empty($sql_users)) { $sql_meta = array(); foreach ($sql_users as $key => $value) { $sql_meta[] = $key; } $statement = __('Deleting User… %s', 'bbpress'); $sql_meta = implode("', '", $sql_meta); $sql_delete = "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}');"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); $statement = __('Deleting User Meta… %s', 'bbpress'); $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}');"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); } } // Next, if we still have users that were not imported delete that meta data $statement = __('Deleting User Meta… %s', 'bbpress'); $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';"; $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success; $messages[] = sprintf($statement, $result); /** Converter *************************************************************/ $statement = __('Deleting Conversion Table… %s', 'bbpress'); $table_name = $bbp_db->prefix . 'bbp_converter_translator'; if ($bbp_db->get_var("SHOW TABLES LIKE '{$table_name}'") === $table_name) { $bbp_db->query("DROP TABLE {$table_name}"); $result = $success; } else { $result = $failed; } $messages[] = sprintf($statement, $result); /** Options ***************************************************************/ $statement = __('Deleting Settings… %s', 'bbpress'); bbp_delete_options(); $messages[] = sprintf($statement, $success); /** Roles *****************************************************************/ $statement = __('Deleting Roles and Capabilities… %s', 'bbpress'); bbp_remove_roles(); bbp_remove_caps(); $messages[] = sprintf($statement, $success); /** Output ****************************************************************/ if (count($messages)) { foreach ($messages as $message) { bbp_admin_tools_feedback($message); } } }
/** * Permissions to view the 'New Topic'/'Reply To' form in a BuddyPress group. * * @since bbPress (r4608) * * @param bool $retval Are we allowed to view the reply form? * @uses bp_is_group() To determine if we're on a group page * @uses is_user_logged_in() To determine if a user is logged in. * @uses bbp_is_user_keymaster() Is the current user a keymaster? * @uses bbp_group_is_member() Is the current user a member of the group? * @uses bbp_group_is_user_banned() Is the current user banned from the group? * * @return bool */ public function form_permissions($retval = false) { // Bail if not a group if (!bp_is_group()) { return $retval; } // Bail if user is not logged in if (!is_user_logged_in()) { return $retval; // Keymasters can always pass go } elseif (bbp_is_user_keymaster()) { $retval = true; // Non-members cannot see forms } elseif (!bbp_group_is_member()) { $retval = false; // Banned users cannot see forms } elseif (bbp_group_is_banned()) { $retval = false; } return $retval; }
static function delete_attachments() { if (isset($_GET['bbpkraction'])) { $nonce = wp_verify_nonce($_GET['_wpnonce'], 'bbpresskr-attachments'); if ($nonce) { global $user_ID; $action = $_GET['bbpkraction']; $att_id = $_GET['att_id']; $bbp_id = $_GET['bbp_id']; $post = get_post($bbp_id); $author_ID = $post->post_author; $file = get_attached_file($att_id); $file = pathinfo($file, PATHINFO_BASENAME); $allow = 'no'; if (bbp_is_user_keymaster()) { $allow = self::$conf['delete_visible_to_admins']; } else { if (current_user_can('moderate')) { $allow = self::$conf['delete_visible_to_moderators']; } else { if ($author_ID == $user_ID) { $allow = self::$conf['delete_visible_to_author']; } } } if ($action == 'delete' && ($allow == 'delete' || $allow == 'both')) { wp_delete_attachment($att_id); } if ($action == 'detach' && ($allow == 'detach' || $allow == 'both')) { global $wpdb; $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $att_id)); } self::collect_attachments($post->ID); } $url = remove_query_arg(array('_wpnonce', 'bbpkraction', 'att_id', 'bbp_id')); wp_redirect($url); exit; } }
function private_group_enforce_permissions() { global $rpg_settingsf; // Bail if not viewing a bbPress item if (!is_bbpress()) { return; } // Bail if not viewing a single item or if user has caps if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_hidden_forums')) { return; } if (!private_groups_check_can_user_view_post()) { if (!is_user_logged_in()) { if ($rpg_settingsf['redirect_page2']) { $link = $rpg_settingsf['redirect_page2']; header("Location: {$link}"); } else { auth_redirect(); } } else { if ($rpg_settingsf['redirect_page1']) { $link = $rpg_settingsf['redirect_page1']; header("Location: {$link}"); } else { bbp_set_404(); } } } }
function pg_forum_dropdown($args = '') { //Get an array of forums which the current user has permissions to view global $wpdb; $forum = bbp_get_forum_post_type(); if (bbp_is_user_keymaster()) { return $args; } $user_id = wp_get_current_user()->ID; if (user_can($user_id, 'moderate')) { $check = get_user_meta($user_id, 'private_group', true); if ($check == '') { return $args; } } $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$forum}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query $allowed_posts = private_groups_get_dropdown_forums($post_ids); // the above generates a list of allowed forums, and we compare this against the original list to create and 'exclude' list $result = array_diff($post_ids, $allowed_posts); $args['exclude'] = $result; return $args; }
/** * Check if it's a private forum or a topic or reply of a private forum and if * the user can't view it, then sets a 404 * * @since bbPress (r2996) * * @uses current_user_can() To check if the current user can read private forums * @uses is_singular() To check if it's a singular page * @uses bbp_is_user_keymaster() To check if user is a keymaster * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses bbp_get_reply_post_type() TO get the reply post type * @uses bbp_get_topic_forum_id() To get the topic forum id * @uses bbp_get_reply_forum_id() To get the reply forum id * @uses bbp_is_forum_private() To check if the forum is private or not * @uses bbp_set_404() To set a 404 status */ function bbp_forum_enforce_private() { // Bail if not viewing a single item or if user has caps if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_private_forums')) { return; } global $wp_query; // Define local variable $forum_id = 0; // Check post type switch ($wp_query->get('post_type')) { // Forum case bbp_get_forum_post_type(): $forum_id = bbp_get_forum_id($wp_query->post->ID); break; // Topic // Topic case bbp_get_topic_post_type(): $forum_id = bbp_get_topic_forum_id($wp_query->post->ID); break; // Reply // Reply case bbp_get_reply_post_type(): $forum_id = bbp_get_reply_forum_id($wp_query->post->ID); break; } // If forum is explicitly hidden and user not capable, set 404 if (!empty($forum_id) && bbp_is_forum_private($forum_id) && !current_user_can('read_private_forums')) { bbp_set_404(); } }
/** * Process bulk dropdown form submission from the WordPress Users * Table * * @uses current_user_can() to check for 'promote users' capability * @uses bbp_get_dynamic_roles() to get forum roles * @uses bbp_get_user_role() to get a user's current forums role * @uses bbp_set_user_role() to set the user's new forums role * @return bool Always false */ public function user_role_bulk_change() { // Bail if no users specified if (empty($_REQUEST['users'])) { return; } // Bail if this isn't a bbPress action if (empty($_REQUEST['bbp-new-role']) || empty($_REQUEST['bbp-change-role'])) { return; } // Check that the new role exists $dynamic_roles = bbp_get_dynamic_roles(); if (empty($dynamic_roles[$_REQUEST['bbp-new-role']])) { return; } // Bail if nonce check fails check_admin_referer('bbp-bulk-users', 'bbp-bulk-users-nonce'); // Bail if current user cannot promote users if (!current_user_can('promote_users')) { return; } // Get the current user ID $current_user_id = (int) bbp_get_current_user_id(); // Run through user ids foreach ((array) $_REQUEST['users'] as $user_id) { $user_id = (int) $user_id; // Don't let a user change their own role if ($user_id === $current_user_id) { continue; } // Set up user and role data $user_role = bbp_get_user_role($user_id); $new_role = sanitize_text_field($_REQUEST['bbp-new-role']); // Only keymasters can set other keymasters if (in_array(bbp_get_keymaster_role(), array($user_role, $new_role)) && !bbp_is_user_keymaster()) { continue; } // Set the new forums role if ($new_role !== $user_role) { bbp_set_user_role($user_id, $new_role); } } }
function bpp_enforce_permissions() { // Bail if not viewing a bbPress item if (!is_bbpress()) { return; } // Bail if not viewing a single item or if user has caps if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_hidden_forums') || bbp_is_forum_archive()) { return; } global $post; if (!$this->bpp_can_user_view_post($post->ID)) { if (!is_user_logged_in()) { if (is_numeric($this->temp)) { $link = get_permalink($this->temp) . '?error=not-accessible'; wp_redirect($link, '302'); exit; } else { auth_redirect(); } } else { if (is_numeric($this->temp)) { wp_safe_redirect(get_permalink($this->temp) . '?error=not-accessible', '302'); } else { bbp_set_404(); } } } }
do_action('bbp_theme_before_reply_author_details'); ?> <?php if (class_exists('userpro_api')) { /* Integrating UserPro */ global $userpro; $link = preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", $userpro->permalink(bbp_get_reply_author_id()), bbp_get_reply_author_link(array('sep' => '', 'show_role' => true, 'size' => 65))); echo $link . userpro_show_badges(bbp_get_reply_author_id()); } else { bbp_reply_author_link(array('sep' => '', 'show_role' => false, 'type' => 'avatar', 'size' => 65)); } ?> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_reply_author_admin_details'); ?> <!-- <div class="bbp-reply-ip"><?php bbp_author_ip(bbp_get_reply_id()); ?> </div> --> <?php do_action('bbp_theme_after_reply_author_admin_details'); ?>
/** * Check if a user is blocked, or cannot spectate the forums. * * @since bbPress (r2996) * * @uses is_user_logged_in() To check if user is logged in * @uses bbp_is_user_keymaster() To check if user is a keymaster * @uses current_user_can() To check if the current user can spectate * @uses is_bbpress() To check if in a bbPress section of the site * @uses bbp_set_404() To set a 404 status */ function bbp_forum_enforce_blocked() { // Bail if not logged in or keymaster if (!is_user_logged_in() || bbp_is_user_keymaster()) { return; } // Set 404 if in bbPress and user cannot spectate if (is_bbpress() && !current_user_can('spectate')) { bbp_set_404(); } }