/** * Is an anonymous topic/reply being made? * * @since bbPres (r2688) * * @uses is_user_logged_in() Is the user logged in? * @uses bbp_allow_anonymous() Is anonymous posting allowed? * @uses apply_filters() Calls 'bbp_is_anonymous' with the return value * @return bool True if anonymous is allowed and user is not logged in, false if * anonymous is not allowed or user is logged in */ function bbp_is_anonymous() { if (!is_user_logged_in() && bbp_allow_anonymous()) { $is_anonymous = true; } else { $is_anonymous = false; } return apply_filters('bbp_is_anonymous', $is_anonymous); }
/** * Check if the current user can publish replies * * @since bbPress (r3127) * * @uses is_super_admin() * @uses is_user_logged_in() * @uses bbp_allow_anonymous() * @uses bbp_is_user_active() * @uses current_user_can() * @uses apply_filters() * * @return bool */ function bbp_current_user_can_publish_replies() { // Users need to earn access $retval = false; // Always allow super admins if (is_super_admin()) { $retval = true; } elseif (!is_user_logged_in() && bbp_allow_anonymous()) { $retval = true; } elseif (current_user_can('publish_replies')) { $retval = true; } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_publish_replies', $retval); }
/** * Check if the current user can publish replies * * @since 2.0.0 bbPress (r3127) * * @uses bbp_is_user_keymaster() * @uses is_user_logged_in() * @uses bbp_allow_anonymous() * @uses bbp_is_user_active() * @uses current_user_can() * @uses apply_filters() * * @return bool */ function bbp_current_user_can_publish_replies() { // Users need to earn access $retval = false; // Always allow keymasters if (bbp_is_user_keymaster()) { $retval = true; // Do not allow anonymous if not enabled } elseif (!is_user_logged_in() && bbp_allow_anonymous()) { $retval = true; // User is logged in } elseif (current_user_can('publish_replies')) { $retval = true; } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_publish_replies', $retval); }
/** * Allow anonymous posting setting field * * @since 2.0.0 bbPress (r2737) * * @uses checked() To display the checked attribute */ function bbp_admin_setting_callback_anonymous() { ?> <input name="_bbp_allow_anonymous" id="_bbp_allow_anonymous" type="checkbox" value="1" <?php checked(bbp_allow_anonymous(false)); bbp_maybe_admin_setting_disabled('_bbp_allow_anonymous'); ?> /> <label for="_bbp_allow_anonymous"><?php esc_html_e('Allow guest users without accounts to create topics and replies', 'bbpress'); ?> </label> <?php }