/** * Use the given query to determine which forums the user has access to. * Return an array of forums which user has permission to access */ function tehnik_bpp_get_permitted_forums($forum_list) { if (function_exists('members_can_user_view_post')) { $filtered_forums = array(); //Get Current User ID $user_id = wp_get_current_user()->ID; foreach ($forum_list as $forum) { $forum_id = $forum->ID; if (members_can_user_view_post($user_id, $forum_id)) { array_push($filtered_forums, $forum); } } return (array) $filtered_forums; } return true; }
/** * Wrapper function for the members_can_user_view_post() function. This function checks if the * currently logged-in user can view the content of a specific post. * * @since 0.2.0 * @access public * @param int $post_id * @return bool */ function members_can_current_user_view_post($post_id = '') { return members_can_user_view_post(get_current_user_id(), $post_id); }
/** * Wrapper function for the members_can_user_view_post() function. This function checks if the currently * logged-in user can view the content of a specific post. * * @since 0.2.0 * @param int $post_id The ID of the post to check. * @return bool True if the user can view the post. False if the user cannot view the post. */ function members_can_current_user_view_post($post_id = '') { /* Get the current user object. */ $current_user = nxt_get_current_user(); /* Return the members_can_user_view_post() function, which returns true/false. */ return members_can_user_view_post($current_user->ID, $post_id); }
function tehnik_bpp_can_user_view_post_id($post_id) { $user_id = wp_get_current_user()->ID; return members_can_user_view_post($user_id, $post_id); }