function buatp_shotcodes($attr, $content = '') { global $bp; $setting = get_option('buatp_basic_setting', true); $defaults = array('user_type' => false, 'include' => false, 'exclude' => false); if (!$content) { $defaults = array_merge($defaults, array('arrange_by' => 'active', 'max' => 10)); } extract(shortcode_atts($defaults, $attr)); $user_type = trim($user_type); $include = trim($include); $exclude = trim($exclude); if ($user_type) { $types = explode(',', $user_type); } if ($content) { if (!$user_type && !$include) { return $content; } if (!is_user_logged_in()) { return buatp_get_content_error_messsage($user_type); } $user_id = $bp->loggedin_user->id; if (current_user_can('edit_post', get_the_ID()) || current_user_can('create_users') || is_super_admin($user_id)) { return $content; } $loggedin_user_type = buatp_get_field_data($setting['buatp_type_field_selection'], $user_id); if ((in_array($loggedin_user_type, $types) || in_array($user_id, explode(',', $include))) && !in_array($user_id, explode(',', $exclude))) { return $content; } else { return buatp_get_content_error_messsage($user_type); } } else { global $query; $query = ''; foreach ((array) $types as $name) { $users = array_merge((array) $users, buatp_get_filtered_members('exclude', $name)); } $query .= $exclude ? "exclude={$exclude}," . implode(',', (array) $users) : "exclude=" . implode(',', (array) $users); if ($arrange_by) { $query .= '&type=' . $arrange_by; } if ($max) { $query .= '&max=' . $max; } add_filter('bp_dtheme_ajax_querystring', create_function('', ' global $query; return $query;'), 1002); add_filter('bp_ajax_querystring', create_function('', ' global $query; return $query;'), 1002); ob_start(); echo '<div id="buddypress">'; require_once apply_filters('buatp_loop', BUATP_TEMPLATE . '/buatp/members-loop.php'); echo '</div>'; $html = ob_get_clean(); return $html; } }
function buatp_get_user_type($user_id) { $settings_basic = get_option('buatp_basic_setting', false); if (!$user_id || !$settings_basic) { return; } return buatp_get_field_data($settings_basic['buatp_type_field_selection'], $user_id); }