/** * 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); }
/** * Hides the new reply form * * @param bool $retval The current state of this permission check * @global int $user_ID The ID of the current user * @return mixed $return */ function edd_cr_hide_new_replies_form($retval) { global $user_ID; if (!current_user_can('moderate') && bbp_current_user_can_publish_replies()) { $restricted_to = edd_cr_is_restricted(bbp_get_topic_id()); $restricted_id = bbp_get_topic_id(); if (!$restricted_to) { $restricted_to = edd_cr_is_restricted(bbp_get_forum_id()); // check for parent forum restriction $restricted_id = bbp_get_forum_id(); if (!$restricted_to) { $ancestors = array_reverse((array) get_post_ancestors(bbp_get_forum_id())); if (!empty($ancestors)) { // Loop through parents foreach ((array) $ancestors as $parent_id) { $restricted_to = edd_cr_is_restricted($parent_id); if ($restricted_to) { break; } } } } } $has_access = edd_cr_user_can_access($user_ID, $restricted_to); if ($has_access['status']) { $retval = true; } } return $retval; }
/** * Performs a series of checks to ensure the current user can create replies. * * @since bbPress (r3127) * * @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 super admins if (is_super_admin()) { $retval = true; } elseif ((bbp_is_single_topic() || is_page() || is_single()) && bbp_is_topic_open() && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_replies(); } 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); }