/** * Performs a series of checks to ensure the current user can create topics. * * @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_topic_form() { // Users need to earn access $retval = false; // Always allow keymasters if (bbp_is_user_keymaster()) { $retval = true; // Looking at a single forum & forum is open } elseif ((bbp_is_single_forum() || is_page() || is_single()) && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_topics(); // User can edit this topic } elseif (bbp_is_topic_edit()) { $retval = current_user_can('edit_topic', bbp_get_topic_id()); } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_create_topic_form', (bool) $retval); }
/** * Hides the new topic form * * @since 1.0.0 * @param string $form The new topic form * @global int $user_ID The ID of the current user * @return mixed $return */ function edd_cr_hide_new_topic_form($form) { global $user_ID; if (!current_user_can('moderate') && bbp_current_user_can_publish_topics()) { $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, $restricted_id); $return = $has_access['status'] == false ? false : true; } else { $return = $form; } return $return; }
function gpbbp_access_topic_form($retval) { $retval = bbp_current_user_can_publish_topics(); return $retval; }
/** * Performs a series of checks to ensure the current user can create topics. * * @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_topic_form() { // Users need to earn access $retval = false; // Always allow super admins if (is_super_admin()) { $retval = true; } elseif ((bbp_is_single_forum() || is_page() || is_single()) && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_topics(); } elseif (bbp_is_topic_edit()) { $retval = current_user_can('edit_topic', bbp_get_topic_id()); } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_create_topic_form', (bool) $retval); }