public function add_change_member_type_selectbox($where = '')
    {
        //Since wp will not pass whether it is for top/bottom, let us use static var to deremine position
        static $position;
        if (!isset($position)) {
            $position = 'top';
            //assume it will be called from top
        } else {
            $position = 'bottom';
        }
        //only admin/super admin
        if (!current_user_can('edit_users')) {
            return;
        }
        $member_types = bp_get_member_types(array(), 'objects');
        if (empty($member_types)) {
            return;
        }
        $output = '<div class="alignright" id="bp-member-type-change-action_' . $position . '">' . '<label for="new_member_type_' . $position . '" class="screen-reader-text">' . __('Change member type to…', 'bp-member-type-generator') . '</label>
					<select id="new_member_type_' . $position . '" name="new_member_type_' . $position . '">
					<option value="">' . __('Change member type to…', 'bp-member-type-generator') . '</option>';
        foreach ($member_types as $key => $type) {
            $output .= sprintf('<option value="%s">%s</option>', esc_attr($key), $type->labels['singular_name']);
        }
        $output .= '</select>';
        $output .= get_submit_button(__('Change', 'bp-member-type-generator'), 'secondary', 'change-member-type', false);
        $output .= '</div>';
        echo $output;
    }
function cfbgr_migrate_xprofile_as_member_types()
{
    global $wpdb;
    $buddypress = buddypress();
    // Description of this tool, displayed to the user
    $statement = __('Migrating/Resetting xProfile data as member types: %s', 'buddypress-group-restrictions');
    // Default to failure text
    $result = __('No xProfile data needs to be migrated or reset.', 'buddypress-group-restrictions');
    // Default to unrepaired
    $repair = 0;
    $field = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (empty($field)) {
        return array(0, sprintf($statement, $result));
    }
    $member_types = bp_get_member_types();
    // Walk through all users on the site
    $user_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
    foreach ($user_ids as $user_id) {
        $value = sanitize_key(xprofile_get_field_data($field, $user_id));
        // Do we have a matching member type ?
        if (isset($member_types[$value])) {
            // Set member types if empty or different
            if ($value !== bp_get_member_type($user_id)) {
                bp_set_member_type($user_id, $value);
                $repair += 1;
            }
        }
    }
    $result = sprintf(__('%d migrated or reset', 'buddypress-group-restrictions'), $repair);
    // All done!
    return array(0, sprintf($statement, $result));
}
 public function field_options($field)
 {
     if ($field->type != 'membertype') {
         return $field;
     }
     $field->display = 'selectbox';
     $field->values = isset($_REQUEST[$field->code]) ? (array) $_REQUEST[$field->code] : array();
     $field->options = array();
     $registered_member_types = bp_get_member_types(null, 'object');
     foreach ($registered_member_types as $type_name => $member_type_object) {
         $field->options[$type_name] = $member_type_object->labels['singular_name'];
     }
     return $field;
 }
        /**
         * Render the Member Type metabox.
         *
         * @since 2.2.0
         *
         * @param WP_User|null $user The WP_User object to be edited.
         */
        public function user_admin_member_type_metabox($user = null)
        {
            // Bail if no user ID.
            if (empty($user->ID)) {
                return;
            }
            $types = bp_get_member_types(array(), 'objects');
            $current_type = bp_get_member_type($user->ID);
            ?>

		<label for="bp-members-profile-member-type" class="screen-reader-text"><?php 
            esc_html_e('Select member type', 'buddypress');
            ?>
</label>
		<select name="bp-members-profile-member-type" id="bp-members-profile-member-type">
			<option value="" <?php 
            selected('', $current_type);
            ?>
><?php 
            /* translators: no option picked in select box */
            esc_attr_e('----', 'buddypress');
            ?>
</option>
			<?php 
            foreach ($types as $type) {
                ?>
				<option value="<?php 
                echo esc_attr($type->name);
                ?>
" <?php 
                selected($type->name, $current_type);
                ?>
><?php 
                echo esc_html($type->labels['singular_name']);
                ?>
</option>
			<?php 
            }
            ?>
		</select>

		<?php 
            wp_nonce_field('bp-member-type-change-' . $user->ID, 'bp-member-type-nonce');
        }
/**
 * Retrieve a member type object by name.
 *
 * @since 2.2.0
 *
 * @param string $member_type The name of the member type.
 * @return object A member type object.
 */
function bp_get_member_type_object($member_type)
{
    $types = bp_get_member_types(array(), 'objects');
    if (empty($types[$member_type])) {
        return null;
    }
    return $types[$member_type];
}
/**
 * Analyze the URI and break it down into BuddyPress-usable chunks.
 *
 * BuddyPress can use complete custom friendly URIs without the user having to
 * add new rewrite rules. Custom components are able to use their own custom
 * URI structures with very little work.
 *
 * The URIs are broken down as follows:
 *   - http:// example.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
 *   - OUTSIDE ROOT: http:// example.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
 *
 *	Example:
 *    - http://example.com/members/andy/profile/edit/group/5/
 *    - $bp->current_component: string 'xprofile'
 *    - $bp->current_action: string 'edit'
 *    - $bp->action_variables: array ['group', 5]
 *
 * @since 1.0.0
 */
function bp_core_set_uri_globals()
{
    global $current_blog, $wp_rewrite;
    // Don't catch URIs on non-root blogs unless multiblog mode is on.
    if (!bp_is_root_blog() && !bp_is_multiblog_mode()) {
        return false;
    }
    $bp = buddypress();
    // Define local variables.
    $root_profile = $match = false;
    $key_slugs = $matches = $uri_chunks = array();
    // Fetch all the WP page names for each component.
    if (empty($bp->pages)) {
        $bp->pages = bp_core_get_directory_pages();
    }
    // Ajax or not?
    if (defined('DOING_AJAX') && DOING_AJAX || strpos($_SERVER['REQUEST_URI'], 'wp-load.php')) {
        $path = bp_get_referer_path();
    } else {
        $path = esc_url($_SERVER['REQUEST_URI']);
    }
    /**
     * Filters the BuddyPress global URI path.
     *
     * @since 1.0.0
     *
     * @param string $path Path to set.
     */
    $path = apply_filters('bp_uri', $path);
    // Take GET variables off the URL to avoid problems.
    $path = strtok($path, '?');
    // Fetch current URI and explode each part separated by '/' into an array.
    $bp_uri = explode('/', $path);
    // Loop and remove empties.
    foreach ((array) $bp_uri as $key => $uri_chunk) {
        if (empty($bp_uri[$key])) {
            unset($bp_uri[$key]);
        }
    }
    // If running off blog other than root, any subdirectory names must be
    // removed from $bp_uri. This includes two cases:
    //
    // 1. when WP is installed in a subdirectory,
    // 2. when BP is running on secondary blog of a subdirectory
    // multisite installation. Phew!
    if (is_multisite() && !is_subdomain_install() && (bp_is_multiblog_mode() || 1 != bp_get_root_blog_id())) {
        // Blow chunks.
        $chunks = explode('/', $current_blog->path);
        // If chunks exist...
        if (!empty($chunks)) {
            // ...loop through them...
            foreach ($chunks as $key => $chunk) {
                $bkey = array_search($chunk, $bp_uri);
                // ...and unset offending keys
                if (false !== $bkey) {
                    unset($bp_uri[$bkey]);
                }
                $bp_uri = array_values($bp_uri);
            }
        }
    }
    // Get site path items.
    $paths = explode('/', bp_core_get_site_path());
    // Take empties off the end of path.
    if (empty($paths[count($paths) - 1])) {
        array_pop($paths);
    }
    // Take empties off the start of path.
    if (empty($paths[0])) {
        array_shift($paths);
    }
    // Reset indexes.
    $bp_uri = array_values($bp_uri);
    $paths = array_values($paths);
    // Unset URI indices if they intersect with the paths.
    foreach ((array) $bp_uri as $key => $uri_chunk) {
        if (isset($paths[$key]) && $uri_chunk == $paths[$key]) {
            unset($bp_uri[$key]);
        }
    }
    // Reset the keys by merging with an empty array.
    $bp_uri = array_merge(array(), $bp_uri);
    // If a component is set to the front page, force its name into $bp_uri
    // so that $current_component is populated (unless a specific WP post is being requested
    // via a URL parameter, usually signifying Preview mode).
    if ('page' == get_option('show_on_front') && get_option('page_on_front') && empty($bp_uri) && empty($_GET['p']) && empty($_GET['page_id'])) {
        $post = get_post(get_option('page_on_front'));
        if (!empty($post)) {
            $bp_uri[0] = $post->post_name;
        }
    }
    // Keep the unfiltered URI safe.
    $bp->unfiltered_uri = $bp_uri;
    // Don't use $bp_unfiltered_uri, this is only for backpat with old plugins. Use $bp->unfiltered_uri.
    $GLOBALS['bp_unfiltered_uri'] =& $bp->unfiltered_uri;
    // Get slugs of pages into array.
    foreach ((array) $bp->pages as $page_key => $bp_page) {
        $key_slugs[$page_key] = trailingslashit('/' . $bp_page->slug);
    }
    // Bail if keyslugs are empty, as BP is not setup correct.
    if (empty($key_slugs)) {
        return;
    }
    // Loop through page slugs and look for exact match to path.
    foreach ($key_slugs as $key => $slug) {
        if ($slug == $path) {
            $match = $bp->pages->{$key};
            $match->key = $key;
            $matches[] = 1;
            break;
        }
    }
    // No exact match, so look for partials.
    if (empty($match)) {
        // Loop through each page in the $bp->pages global.
        foreach ((array) $bp->pages as $page_key => $bp_page) {
            // Look for a match (check members first).
            if (in_array($bp_page->name, (array) $bp_uri)) {
                // Match found, now match the slug to make sure.
                $uri_chunks = explode('/', $bp_page->slug);
                // Loop through uri_chunks.
                foreach ((array) $uri_chunks as $key => $uri_chunk) {
                    // Make sure chunk is in the correct position.
                    if (!empty($bp_uri[$key]) && $bp_uri[$key] == $uri_chunk) {
                        $matches[] = 1;
                        // No match.
                    } else {
                        $matches[] = 0;
                    }
                }
                // Have a match.
                if (!in_array(0, (array) $matches)) {
                    $match = $bp_page;
                    $match->key = $page_key;
                    break;
                }
                // Unset matches.
                unset($matches);
            }
            // Unset uri chunks.
            unset($uri_chunks);
        }
    }
    // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above.
    if (empty($matches) && bp_core_enable_root_profiles()) {
        // Switch field based on compat.
        $field = bp_is_username_compatibility_mode() ? 'login' : 'slug';
        // Make sure there's a user corresponding to $bp_uri[0].
        if (!empty($bp->pages->members) && !empty($bp_uri[0]) && ($root_profile = get_user_by($field, $bp_uri[0]))) {
            // Force BP to recognize that this is a members page.
            $matches[] = 1;
            $match = $bp->pages->members;
            $match->key = 'members';
        }
    }
    // Search doesn't have an associated page, so we check for it separately.
    if (!empty($bp_uri[0]) && bp_get_search_slug() == $bp_uri[0]) {
        $matches[] = 1;
        $match = new stdClass();
        $match->key = 'search';
        $match->slug = bp_get_search_slug();
    }
    // This is not a BuddyPress page, so just return.
    if (empty($matches)) {
        return false;
    }
    $wp_rewrite->use_verbose_page_rules = false;
    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works.
    $slug = !empty($match) ? explode('/', $match->slug) : '';
    $uri_offset = empty($root_profile) ? 0 : -1;
    // Rejig the offset.
    if (!empty($slug) && 1 < count($slug)) {
        // Only offset if not on a root profile. Fixes issue when Members page is nested.
        if (false === $root_profile) {
            array_pop($slug);
            $uri_offset = count($slug);
        }
    }
    // Global the unfiltered offset to use in bp_core_load_template().
    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0.
    $bp->unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    // We have an exact match.
    if (isset($match->key)) {
        // Set current component to matched key.
        $bp->current_component = $match->key;
        // If members component, do more work to find the actual component.
        if ('members' == $match->key) {
            $after_member_slug = false;
            if (!empty($bp_uri[$uri_offset + 1])) {
                $after_member_slug = $bp_uri[$uri_offset + 1];
            }
            // Are we viewing a specific user?
            if ($after_member_slug) {
                // If root profile, we've already queried for the user.
                if ($root_profile instanceof WP_User) {
                    $bp->displayed_user->id = $root_profile->ID;
                    // Switch the displayed_user based on compatibility mode.
                } elseif (bp_is_username_compatibility_mode()) {
                    $bp->displayed_user->id = (int) bp_core_get_userid(urldecode($after_member_slug));
                } else {
                    $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename($after_member_slug);
                }
            }
            // Is this a member type directory?
            if (!bp_displayed_user_id() && $after_member_slug === apply_filters('bp_members_member_type_base', _x('type', 'member type URL base', 'buddypress')) && !empty($bp_uri[$uri_offset + 2])) {
                $matched_types = bp_get_member_types(array('has_directory' => true, 'directory_slug' => $bp_uri[$uri_offset + 2]));
                if (!empty($matched_types)) {
                    $bp->current_member_type = reset($matched_types);
                    unset($bp_uri[$uri_offset + 1]);
                }
            }
            // If the slug matches neither a member type nor a specific member, 404.
            if (!bp_displayed_user_id() && !bp_get_current_member_type() && $after_member_slug) {
                // Prevent components from loading their templates.
                $bp->current_component = '';
                bp_do_404();
                return;
            }
            // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin).
            if (bp_displayed_user_id() && bp_is_user_spammer(bp_displayed_user_id())) {
                if (bp_current_user_can('bp_moderate')) {
                    bp_core_add_message(__('This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress'), 'warning');
                } else {
                    bp_do_404();
                    return;
                }
            }
            // Bump the offset.
            if (bp_displayed_user_id()) {
                if (isset($bp_uri[$uri_offset + 2])) {
                    $bp_uri = array_merge(array(), array_slice($bp_uri, $uri_offset + 2));
                    $bp->current_component = $bp_uri[0];
                    // No component, so default will be picked later.
                } else {
                    $bp_uri = array_merge(array(), array_slice($bp_uri, $uri_offset + 2));
                    $bp->current_component = '';
                }
                // Reset the offset.
                $uri_offset = 0;
            }
        }
    }
    // Determine the current action.
    $current_action = isset($bp_uri[$uri_offset + 1]) ? $bp_uri[$uri_offset + 1] : '';
    /*
     * If a BuddyPress directory is set to the WP front page, URLs like example.com/members/?s=foo
     * shouldn't interfere with blog searches.
     */
    if (empty($current_action) && !empty($_GET['s']) && 'page' == get_option('show_on_front') && !empty($match->id)) {
        $page_on_front = (int) get_option('page_on_front');
        if ((int) $match->id === $page_on_front) {
            $bp->current_component = '';
            return false;
        }
    }
    $bp->current_action = $current_action;
    // Slice the rest of the $bp_uri array and reset offset.
    $bp_uri = array_slice($bp_uri, $uri_offset + 2);
    $uri_offset = 0;
    // Set the entire URI as the action variables, we will unset the current_component and action in a second.
    $bp->action_variables = $bp_uri;
    // Reset the keys by merging with an empty array.
    $bp->action_variables = array_merge(array(), $bp->action_variables);
}
Exemple #7
0
</h1>
                <p><?php 
_e('Import your existing member types, that were created <strong>Manually with Code</strong> or from another <strong>Plugin</strong> ( needs to be active )', 'bp-member-types');
?>
</p><br/>

                <input type="submit" value="Run Migration" id="bmt-import-submit" name="bmt-import-submit" class="button-primary">
            </div>
        </form>
    </div>
</div>
<br />

<?php 
if (isset($_POST['bmt-import-submit'])) {
    $registered_member_types = bp_get_member_types();
    $created_member_types = bmt_get_active_member_types();
    $active_member_types = array();
    foreach ($created_member_types as $created_member_type) {
        $name = strtolower(get_post_meta($created_member_type, '_bp_member_type_label_singular_name', true));
        $name = str_replace(array(' ', ','), array('-', '-'), $name);
        array_push($active_member_types, $name);
    }
    $registered_member_types = array_diff($registered_member_types, $active_member_types);
    if (empty($registered_member_types)) {
        ?>
            <div class="wrap">
                <div class="error notice " id="message"><p><?php 
        _e('Nothing to import');
        ?>
</p></div>
/**
 * Handles the WYSIWYG display of each profile field on the edit screen.
 *
 * @since 1.5.0
 *
 * @param object $admin_field Admin field.
 * @param object $admin_group Admin group object.
 * @param string $class       Classes to append to output.
 */
function xprofile_admin_field($admin_field, $admin_group, $class = '')
{
    global $field;
    $field = $admin_field;
    ?>

	<fieldset id="draggable_field_<?php 
    echo esc_attr($field->id);
    ?>
"class="sortable<?php 
    echo ' ' . $field->type;
    if (!empty($class)) {
        echo ' ' . $class;
    }
    ?>
">
		<legend>
			<span>
				<?php 
    bp_the_profile_field_name();
    ?>

				<?php 
    if (empty($field->can_delete)) {
        esc_html_e('(Primary)', 'buddypress');
    }
    ?>
				<?php 
    bp_the_profile_field_required_label();
    ?>
				<?php 
    if (bp_xprofile_get_meta($field->id, 'field', 'signup_position')) {
        esc_html_e('(Sign-up)', 'buddypress');
    }
    ?>
				<?php 
    if (bp_get_member_types()) {
        echo $field->get_member_type_label();
    }
    ?>

				<?php 
    /**
     * Fires at end of legend above the name field in base xprofile group.
     *
     * @since 2.2.0
     *
     * @param BP_XProfile_Field $field Current BP_XProfile_Field
     *                                 object being rendered.
     */
    do_action('xprofile_admin_field_name_legend', $field);
    ?>
			</span>
		</legend>
		<div class="field-wrapper">

			<?php 
    if (in_array($field->type, array_keys(bp_xprofile_get_field_types()))) {
        $field_type = bp_xprofile_create_field_type($field->type);
        $field_type->admin_field_html();
    } else {
        /**
         * Fires after the input if the current field is not in default field types.
         *
         * @since 1.5.0
         *
         * @param BP_XProfile_Field $field Current BP_XProfile_Field
         *                                 object being rendered.
         * @param int               $value Integer 1.
         */
        do_action('xprofile_admin_field', $field, 1);
    }
    ?>

			<?php 
    if ($field->description) {
        ?>

				<p class="description"><?php 
        echo esc_attr($field->description);
        ?>
</p>

			<?php 
    }
    ?>

			<div class="actions">
				<a class="button edit" href="users.php?page=bp-profile-setup&amp;group_id=<?php 
    echo esc_attr($admin_group->id);
    ?>
&amp;field_id=<?php 
    echo esc_attr($field->id);
    ?>
&amp;mode=edit_field"><?php 
    _e('Edit', 'buddypress');
    ?>
</a>

				<?php 
    if ($field->can_delete) {
        ?>

					<div class="delete-button">
						<a class="confirm submit-delete deletion" href="users.php?page=bp-profile-setup&amp;field_id=<?php 
        echo esc_attr($field->id);
        ?>
&amp;mode=delete_field"><?php 
        _e('Delete', 'buddypress');
        ?>
</a>
					</div>

				<?php 
    }
    ?>

				<?php 
    /**
     * Fires at end of field management links in xprofile management admin.
     *
     * @since 2.2.0
     *
     * @param BP_XProfile_Group $group BP_XProfile_Group object
     *                                 for the current group.
     */
    do_action('xprofile_admin_field_action', $field);
    ?>

			</div>
		</div>
	</fieldset>

<?php 
}
 /**
  * Get member types as associative array
  * 
  * @staticvar array $member_types
  * @return array
  */
 private static function get_member_types()
 {
     static $member_types = null;
     if (isset($member_types)) {
         return $member_types;
     }
     $registered_member_types = bp_get_member_types(null, 'object');
     if (empty($registered_member_types)) {
         $member_types = $registered_member_types;
         return $member_types;
     }
     foreach ($registered_member_types as $type_name => $member_type_object) {
         $member_types[$type_name] = $member_type_object->labels['singular_name'];
     }
     return $member_types;
 }
/**
 * Locate a custom user front template if it exists.
 *
 * @since 2.6.0
 *
 * @param  object|null $displayed_user Optional. Falls back to current user if not passed.
 * @return string|bool                 Path to front template on success; boolean false on failure.
 */
function bp_displayed_user_get_front_template($displayed_user = null)
{
    if (!is_object($displayed_user) || empty($displayed_user->id)) {
        $displayed_user = bp_get_displayed_user();
    }
    if (!isset($displayed_user->id)) {
        return false;
    }
    if (isset($displayed_user->front_template)) {
        return $displayed_user->front_template;
    }
    // Init the hierarchy
    $template_names = array('members/single/front-id-' . sanitize_file_name($displayed_user->id) . '.php', 'members/single/front-nicename-' . sanitize_file_name($displayed_user->userdata->user_nicename) . '.php');
    /**
     * Check for member types and add it to the hierarchy
     *
     * Make sure to register your member
     * type using the hook 'bp_register_member_types'
     */
    if (bp_get_member_types()) {
        $displayed_user_member_type = bp_get_member_type($displayed_user->id);
        if (!$displayed_user_member_type) {
            $displayed_user_member_type = 'none';
        }
        $template_names[] = 'members/single/front-member-type-' . sanitize_file_name($displayed_user_member_type) . '.php';
    }
    // Add The generic template to the end of the hierarchy
    $template_names[] = 'members/single/front.php';
    /**
     * Filters the hierarchy of user front templates corresponding to a specific user.
     *
     * @since 2.6.0
     *
     * @param array  $template_names Array of template paths.
     */
    return bp_locate_template(apply_filters('bp_displayed_user_get_front_template', $template_names), false, true);
}
    /**
     * Private method used to output field Member Type metabox.
     *
     * @since 2.4.0
     */
    private function member_type_metabox()
    {
        // The primary field is for all, so bail.
        if (1 === (int) $this->id) {
            return;
        }
        // Bail when no member types are registered.
        if (!($member_types = bp_get_member_types(array(), 'objects'))) {
            return;
        }
        $field_member_types = $this->get_member_types();
        ?>

		<div id="member-types-div" class="postbox">
			<h2><?php 
        _e('Member Types', 'buddypress');
        ?>
</h2>
			<div class="inside">
				<p class="description"><?php 
        _e('This field should be available to:', 'buddypress');
        ?>
</p>

				<ul>
					<?php 
        foreach ($member_types as $member_type) {
            ?>
					<li>
						<label for="member-type-<?php 
            echo $member_type->labels['name'];
            ?>
">
							<input name="member-types[]" id="member-type-<?php 
            echo $member_type->labels['name'];
            ?>
" class="member-type-selector" type="checkbox" value="<?php 
            echo $member_type->name;
            ?>
" <?php 
            checked(in_array($member_type->name, $field_member_types));
            ?>
/>
							<?php 
            echo $member_type->labels['name'];
            ?>
						</label>
					</li>
					<?php 
        }
        ?>

					<li>
						<label for="member-type-none">
							<input name="member-types[]" id="member-type-none" class="member-type-selector" type="checkbox" value="null" <?php 
        checked(in_array('null', $field_member_types));
        ?>
/>
							<?php 
        _e('Users with no member type', 'buddypress');
        ?>
						</label>
					</li>

				</ul>
				<p class="description member-type-none-notice<?php 
        if (!empty($field_member_types)) {
            ?>
 hide<?php 
        }
        ?>
"><?php 
        _e('Unavailable to all members.', 'buddypress');
        ?>
</p>
			</div>

			<input type="hidden" name="has-member-types" value="1" />
		</div>

		<?php 
    }
Exemple #12
0
function kleo_bp_set_has_members_type_arg($args)
{
    $member_type = bp_get_current_member_type();
    $member_types = bp_get_member_types(array(), 'names');
    if (isset($args['scope']) && !isset($args['member_type']) && in_array($args['scope'], $member_types)) {
        if ($member_type) {
            unset($args['scope']);
        } else {
            $args['member_type'] = $args['scope'];
        }
    }
    return $args;
}
 /**
  * Populates the BP_XProfile_Group object with profile field groups, fields,
  * and field data
  *
  * @package BuddyPress XProfile
  *
  * @global object $wpdb WordPress DB access object.
  *
  * @param array $args {
  *  Array of optional arguments:
  *      @type int          $profile_group_id  Limit results to a single profile group.
  *      @type int          $user_id           Required if you want to load a specific user's data.
  *                                            Default: displayed user's ID.
  *      @type array|string $member_type       Limit fields by those restricted to a given member type, or array of
  *                                            member types. If `$user_id` is provided, the value of `$member_type`
  *                                            will be overridden by the member types of the provided user. The
  *                                            special value of 'any' will return only those fields that are
  *                                            unrestricted by member type - i.e., those applicable to any type.
  *      @type bool         $hide_empty_groups True to hide groups that don't have any fields. Default: false.
  *      @type bool         $hide_empty_fields True to hide fields where the user has not provided data.
  *                                            Default: false.
  *      @type bool         $fetch_fields      Whether to fetch each group's fields. Default: false.
  *      @type bool         $fetch_field_data  Whether to fetch data for each field. Requires a $user_id.
  *                                            Default: false.
  *      @type array        $exclude_groups    Comma-separated list or array of group IDs to exclude.
  *      @type array        $exclude_fields    Comma-separated list or array of field IDs to exclude.
  *      @type bool         $update_meta_cache Whether to pre-fetch xprofilemeta for all retrieved groups, fields,
  *                                            and data. Default: true.
  * }
  * @return array $groups
  */
 public static function get($args = array())
 {
     global $wpdb;
     // Parse arguments.
     $r = wp_parse_args($args, array('profile_group_id' => false, 'user_id' => bp_displayed_user_id(), 'member_type' => false, 'hide_empty_groups' => false, 'hide_empty_fields' => false, 'fetch_fields' => false, 'fetch_field_data' => false, 'fetch_visibility_level' => false, 'exclude_groups' => false, 'exclude_fields' => false, 'update_meta_cache' => true));
     // Keep track of object IDs for cache-priming.
     $object_ids = array('group' => array(), 'field' => array(), 'data' => array());
     // WHERE.
     if (!empty($r['profile_group_id'])) {
         $where_sql = $wpdb->prepare('WHERE g.id = %d', $r['profile_group_id']);
     } elseif ($r['exclude_groups']) {
         $exclude = join(',', wp_parse_id_list($r['exclude_groups']));
         $where_sql = "WHERE g.id NOT IN ({$exclude})";
     } else {
         $where_sql = '';
     }
     $bp = buddypress();
     // Include or exclude empty groups.
     if (!empty($r['hide_empty_groups'])) {
         $group_ids = $wpdb->get_col("SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id {$where_sql} ORDER BY g.group_order ASC");
     } else {
         $group_ids = $wpdb->get_col("SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g {$where_sql} ORDER BY g.group_order ASC");
     }
     // Get all group data.
     $groups = self::get_group_data($group_ids);
     // Bail if not also getting fields.
     if (empty($r['fetch_fields'])) {
         return $groups;
     }
     // Get the group ids from the groups we found.
     $group_ids = wp_list_pluck($groups, 'id');
     // Store for meta cache priming.
     $object_ids['group'] = $group_ids;
     // Bail if no groups found.
     if (empty($group_ids)) {
         return $groups;
     }
     // Setup IN query from group IDs.
     $group_ids_in = implode(',', (array) $group_ids);
     // Support arrays and comma-separated strings.
     $exclude_fields_cs = wp_parse_id_list($r['exclude_fields']);
     // Visibility - Handled here so as not to be overridden by sloppy use of the
     // exclude_fields parameter. See bp_xprofile_get_hidden_fields_for_user().
     $hidden_user_fields = bp_xprofile_get_hidden_fields_for_user($r['user_id']);
     $exclude_fields_cs = array_merge($exclude_fields_cs, $hidden_user_fields);
     $exclude_fields_cs = implode(',', $exclude_fields_cs);
     // Set up NOT IN query for excluded field IDs.
     if (!empty($exclude_fields_cs)) {
         $exclude_fields_sql = "AND id NOT IN ({$exclude_fields_cs})";
     } else {
         $exclude_fields_sql = '';
     }
     // Set up IN query for included field IDs.
     $include_field_ids = array();
     // Member-type restrictions.
     if (bp_get_member_types()) {
         if ($r['user_id'] || false !== $r['member_type']) {
             $member_types = $r['member_type'];
             if ($r['user_id']) {
                 $member_types = bp_get_member_type($r['user_id'], false);
                 if (empty($member_types)) {
                     $member_types = array('null');
                 }
             }
             $member_types_fields = BP_XProfile_Field::get_fields_for_member_type($member_types);
             $include_field_ids += array_keys($member_types_fields);
         }
     }
     $in_sql = '';
     if (!empty($include_field_ids)) {
         $include_field_ids_cs = implode(',', array_map('intval', $include_field_ids));
         $in_sql = " AND id IN ({$include_field_ids_cs}) ";
     }
     // Fetch the fields.
     $field_ids = $wpdb->get_col("SELECT id FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids_in} ) AND parent_id = 0 {$exclude_fields_sql} {$in_sql} ORDER BY field_order");
     // Bail if no fields.
     if (empty($field_ids)) {
         return $groups;
     }
     $field_ids = array_map('intval', $field_ids);
     // Prime the field cache.
     $uncached_field_ids = bp_get_non_cached_ids($field_ids, 'bp_xprofile_fields');
     if (!empty($uncached_field_ids)) {
         $_uncached_field_ids = implode(',', array_map('intval', $uncached_field_ids));
         $uncached_fields = $wpdb->get_results("SELECT * FROM {$bp->profile->table_name_fields} WHERE id IN ({$_uncached_field_ids})");
         foreach ($uncached_fields as $uncached_field) {
             $fid = intval($uncached_field->id);
             wp_cache_set($fid, $uncached_field, 'bp_xprofile_fields');
         }
     }
     // Pull field objects from the cache.
     $fields = array();
     foreach ($field_ids as $field_id) {
         $fields[] = xprofile_get_field($field_id);
     }
     // Store field IDs for meta cache priming.
     $object_ids['field'] = $field_ids;
     // Maybe fetch field data.
     if (!empty($r['fetch_field_data'])) {
         // Get field data for user ID.
         if (!empty($field_ids) && !empty($r['user_id'])) {
             $field_data = BP_XProfile_ProfileData::get_data_for_user($r['user_id'], $field_ids);
         }
         // Remove data-less fields, if necessary.
         if (!empty($r['hide_empty_fields']) && !empty($field_ids) && !empty($field_data)) {
             // Loop through the results and find the fields that have data.
             foreach ((array) $field_data as $data) {
                 // Empty fields may contain a serialized empty array.
                 $maybe_value = maybe_unserialize($data->value);
                 // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731.
                 if ((!empty($maybe_value) || '0' == $maybe_value) && false !== ($key = array_search($data->field_id, $field_ids))) {
                     // Fields that have data get removed from the list.
                     unset($field_ids[$key]);
                 }
             }
             // The remaining members of $field_ids are empty. Remove them.
             foreach ($fields as $field_key => $field) {
                 if (in_array($field->id, $field_ids)) {
                     unset($fields[$field_key]);
                 }
             }
             // Reset indexes.
             $fields = array_values($fields);
         }
         // Field data was found.
         if (!empty($fields) && !empty($field_data) && !is_wp_error($field_data)) {
             // Loop through fields.
             foreach ((array) $fields as $field_key => $field) {
                 // Loop through the data in each field.
                 foreach ((array) $field_data as $data) {
                     // Assign correct data value to the field.
                     if ($field->id == $data->field_id) {
                         $fields[$field_key]->data = new stdClass();
                         $fields[$field_key]->data->value = $data->value;
                         $fields[$field_key]->data->id = $data->id;
                     }
                     // Store for meta cache priming.
                     $object_ids['data'][] = $data->id;
                 }
             }
         }
     }
     // Prime the meta cache, if necessary.
     if (!empty($r['update_meta_cache'])) {
         bp_xprofile_update_meta_cache($object_ids);
     }
     // Maybe fetch visibility levels.
     if (!empty($r['fetch_visibility_level'])) {
         $fields = self::fetch_visibility_level($r['user_id'], $fields);
     }
     // Merge the field array back in with the group array.
     foreach ((array) $groups as $group) {
         // Indexes may have been shifted after previous deletions, so we get a
         // fresh one each time through the loop.
         $index = array_search($group, $groups);
         foreach ((array) $fields as $field) {
             if ($group->id === $field->group_id) {
                 $groups[$index]->fields[] = $field;
             }
         }
         // When we unset fields above, we may have created empty groups.
         // Remove them, if necessary.
         if (empty($group->fields) && !empty($r['hide_empty_groups'])) {
             unset($groups[$index]);
         }
         // Reset indexes.
         $groups = array_values($groups);
     }
     return $groups;
 }
function bps_get_fields()
{
    global $group, $field;
    static $groups = array();
    static $fields = array();
    if (count($groups)) {
        return array($groups, $fields);
    }
    if (!function_exists('bp_has_profile')) {
        printf('<p class="bps_error">' . __('%s: The BuddyPress Extended Profiles component is not active.', 'bp-profile-search') . '</p>', '<strong>BP Profile Search ' . BPS_VERSION . '</strong>');
        return array($groups, $fields);
    }
    $args = array('hide_empty_fields' => false, 'member_type' => bp_get_member_types());
    if (bp_has_profile($args)) {
        while (bp_profile_groups()) {
            bp_the_profile_group();
            $group->name = str_replace('&amp;', '&', stripslashes($group->name));
            $groups[$group->name] = array();
            while (bp_profile_fields()) {
                bp_the_profile_field();
                $field->name = str_replace('&amp;', '&', stripslashes($field->name));
                $field->description = str_replace('&amp;', '&', stripslashes($field->description));
                $groups[$group->name][] = array('id' => $field->id, 'name' => $field->name);
                $fields[$field->id] = $field;
            }
        }
    }
    list($groups, $fields) = apply_filters('bps_get_fields', array($groups, $fields));
    return array($groups, $fields);
}
/**
 * Enqueues the Rendez Vous editor scripts, css, settings and strings
 *
 * Inspired by wp_enqueue_media()
 *
 * @package Rendez Vous
 * @subpackage Editor
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_enqueue_editor($args = array())
{
    // Enqueue me just once per page, please.
    if (did_action('rendez_vous_enqueue_editor')) {
        return;
    }
    $defaults = array('post' => null, 'user_id' => bp_loggedin_user_id(), 'callback' => null, 'group_id' => null);
    $args = wp_parse_args($args, $defaults);
    // We're going to pass the old thickbox media tabs to `media_upload_tabs`
    // to ensure plugins will work. We will then unset those tabs.
    $tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => '');
    $tabs = apply_filters('media_upload_tabs', $tabs);
    unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']);
    $props = array('link' => bp_get_option('image_default_link_type'), 'align' => bp_get_option('image_default_align'), 'size' => bp_get_option('image_default_size'));
    $settings = array('tabs' => $tabs, 'tabUrl' => esc_url(add_query_arg(array('chromeless' => true), admin_url('admin-ajax.php'))), 'mimeTypes' => false, 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor'), 'rendezvous' => wp_create_nonce('rendez-vous-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'embedExts' => false);
    $post = $hier = null;
    $settings['user'] = intval($args['user_id']);
    $settings['group_id'] = intval($args['group_id']);
    if (!empty($args['callback'])) {
        $settings['callback'] = esc_url($args['callback']);
    }
    // Do we have member types ?
    $rendez_vous_member_types = array();
    $member_types = bp_get_member_types(array(), 'objects');
    if (!empty($member_types) && is_array($member_types)) {
        $rendez_vous_member_types['rdvMemberTypesAll'] = esc_html__('All member types', 'rendez-vous');
        foreach ($member_types as $type_key => $type) {
            $rendez_vous_member_types['rdvMemberTypes'][] = array('type' => $type_key, 'text' => esc_html($type->labels['singular_name']));
        }
    }
    if (!empty($rendez_vous_member_types)) {
        $settings = array_merge($settings, $rendez_vous_member_types);
    }
    $strings = array('url' => __('URL', 'rendez-vous'), 'addMedia' => __('Add Media', 'rendez-vous'), 'search' => __('Search', 'rendez-vous'), 'select' => __('Select', 'rendez-vous'), 'cancel' => __('Cancel', 'rendez-vous'), 'selected' => __('%d selected', 'rendez-vous'), 'dragInfo' => __('Drag and drop to reorder images.', 'rendez-vous'), 'uploadFilesTitle' => __('Upload Files', 'rendez-vous'), 'uploadImagesTitle' => __('Upload Images', 'rendez-vous'), 'mediaLibraryTitle' => __('Media Library', 'rendez-vous'), 'insertMediaTitle' => __('Insert Media', 'rendez-vous'), 'createNewGallery' => __('Create a new gallery', 'rendez-vous'), 'returnToLibrary' => __('&#8592; Return to library', 'rendez-vous'), 'allMediaItems' => __('All media items', 'rendez-vous'), 'noItemsFound' => __('No items found.', 'rendez-vous'), 'insertIntoPost' => $hier ? __('Insert into page', 'rendez-vous') : __('Insert into post', 'rendez-vous'), 'uploadedToThisPost' => $hier ? __('Uploaded to this page', 'rendez-vous') : __('Uploaded to this post', 'rendez-vous'), 'warnDelete' => __("You are about to permanently delete this item.\n  'Cancel' to stop, 'OK' to delete.", 'rendez-vous'), 'insertFromUrlTitle' => __('Insert from URL', 'rendez-vous'), 'setFeaturedImageTitle' => __('Set Featured Image', 'rendez-vous'), 'setFeaturedImage' => __('Set featured image', 'rendez-vous'), 'createGalleryTitle' => __('Create Gallery', 'rendez-vous'), 'editGalleryTitle' => __('Edit Gallery', 'rendez-vous'), 'cancelGalleryTitle' => __('&#8592; Cancel Gallery', 'rendez-vous'), 'insertGallery' => __('Insert gallery', 'rendez-vous'), 'updateGallery' => __('Update gallery', 'rendez-vous'), 'addToGallery' => __('Add to gallery', 'rendez-vous'), 'addToGalleryTitle' => __('Add to Gallery', 'rendez-vous'), 'reverseOrder' => __('Reverse order', 'rendez-vous'));
    $rendez_vous_strings = apply_filters('rendez_vous_view_strings', array('rdvMainTitle' => _x('Rendez-vous', 'RendezVous editor main title', 'rendez-vous'), 'whatTab' => _x('What?', 'RendezVous editor tab what name', 'rendez-vous'), 'whenTab' => _x('When?', 'RendezVous editor tab when name', 'rendez-vous'), 'whoTab' => _x('Who?', 'RendezVous editor tab who name', 'rendez-vous'), 'rdvInsertBtn' => __('Add to invites', 'rendez-vous'), 'rdvNextBtn' => __('Next', 'rendez-vous'), 'rdvPrevBtn' => __('Prev', 'rendez-vous'), 'rdvSrcPlaceHolder' => __('Search', 'rendez-vous'), 'invited' => __('%d to invite', 'rendez-vous'), 'removeInviteBtn' => __('Remove Invite', 'rendez-vous'), 'saveButton' => __('Save Rendez-Vous', 'rendez-vous')));
    // Use the filter at your own risks!
    $rendez_vous_fields = array('what' => apply_filters('rendez_vous_editor_core_fields', array(array('id' => 'title', 'order' => 0, 'type' => 'text', 'placeholder' => esc_html__('What is this about ?', 'rendez-vous'), 'label' => esc_html__('Title', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'venue', 'order' => 10, 'type' => 'text', 'placeholder' => esc_html__('Where ?', 'rendez-vous'), 'label' => esc_html__('Venue', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'description', 'order' => 20, 'type' => 'textarea', 'placeholder' => esc_html__('Some details about this rendez-vous ?', 'rendez-vous'), 'label' => esc_html__('Description', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'duration', 'order' => 30, 'type' => 'duree', 'placeholder' => '00:00', 'label' => esc_html__('Duration', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'privacy', 'order' => 40, 'type' => 'checkbox', 'placeholder' => esc_html__('Restrict to the selected members of the Who? tab', 'rendez-vous'), 'label' => esc_html__('Access', 'rendez-vous'), 'value' => '0', 'tab' => 'what', 'class' => ''), array('id' => 'utcoffset', 'order' => 50, 'type' => 'timezone', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''))));
    // Do we have rendez-vous types ?
    if (rendez_vous_has_types()) {
        $rendez_vous_types_choices = array();
        $rendez_vous_types_placeholder = array();
        foreach (rendez_vous()->types as $rendez_vous_type) {
            $rendez_vous_types_choices[] = $rendez_vous_type->term_id;
            $rendez_vous_types_placeholder[] = $rendez_vous_type->name;
        }
        // Set the rendez-voys types field arg
        $rendez_vous_types_args = array('id' => 'type', 'order' => 15, 'type' => 'selectbox', 'placeholder' => $rendez_vous_types_placeholder, 'label' => esc_html__('Type', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => '', 'choices' => $rendez_vous_types_choices);
        // Merge with other rendez-vous fields
        $rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], array($rendez_vous_types_args));
    }
    /**
     * Use 'rendez_vous_editor_extra_fields' to add custom fields, you should be able
     * to save them using the 'rendez_vous_after_saved' action.
     */
    $rendez_vous_extra_fields = apply_filters('rendez_vous_editor_extra_fields', array());
    $rendez_vous_add_fields = array();
    if (!empty($rendez_vous_extra_fields) && is_array($rendez_vous_extra_fields)) {
        // Some id are restricted to the plugin usage
        $restricted = array('title' => true, 'venue' => true, 'type' => true, 'description' => true, 'duration' => true, 'privacy' => true, 'utcoffset' => true);
        foreach ($rendez_vous_extra_fields as $rendez_vous_extra_field) {
            // The id is required and some ids are restricted.
            if (empty($rendez_vous_extra_field['id']) || !empty($restricted[$rendez_vous_extra_field['id']])) {
                continue;
            }
            // Make sure all needed arguments have default values
            $rendez_vous_add_fields[] = wp_parse_args($rendez_vous_extra_field, array('id' => '', 'order' => 60, 'type' => 'text', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''));
        }
    }
    if (!empty($rendez_vous_add_fields)) {
        $rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], $rendez_vous_add_fields);
    }
    // Sort by the order key
    $rendez_vous_fields['what'] = bp_sort_by_key($rendez_vous_fields['what'], 'order', 'num');
    $rendez_vous_date_strings = array('daynames' => array(esc_html__('Sunday', 'rendez-vous'), esc_html__('Monday', 'rendez-vous'), esc_html__('Tuesday', 'rendez-vous'), esc_html__('Wednesday', 'rendez-vous'), esc_html__('Thursday', 'rendez-vous'), esc_html__('Friday', 'rendez-vous'), esc_html__('Saturday', 'rendez-vous')), 'daynamesmin' => array(esc_html__('Su', 'rendez-vous'), esc_html__('Mo', 'rendez-vous'), esc_html__('Tu', 'rendez-vous'), esc_html__('We', 'rendez-vous'), esc_html__('Th', 'rendez-vous'), esc_html__('Fr', 'rendez-vous'), esc_html__('Sa', 'rendez-vous')), 'monthnames' => array(esc_html__('January', 'rendez-vous'), esc_html__('February', 'rendez-vous'), esc_html__('March', 'rendez-vous'), esc_html__('April', 'rendez-vous'), esc_html__('May', 'rendez-vous'), esc_html__('June', 'rendez-vous'), esc_html__('July', 'rendez-vous'), esc_html__('August', 'rendez-vous'), esc_html__('September', 'rendez-vous'), esc_html__('October', 'rendez-vous'), esc_html__('November', 'rendez-vous'), esc_html__('December', 'rendez-vous')), 'format' => _x('mm/dd/yy', 'rendez-vous date format', 'rendez-vous'), 'firstday' => intval(bp_get_option('start_of_week', 0)), 'alert' => esc_html__('You already selected this date', 'rendez-vous'));
    $settings = apply_filters('media_view_settings', $settings, $post);
    $strings = apply_filters('media_view_strings', $strings, $post);
    $strings = array_merge($strings, array('rendez_vous_strings' => $rendez_vous_strings, 'rendez_vous_fields' => $rendez_vous_fields, 'rendez_vous_date_strings' => $rendez_vous_date_strings));
    $strings['settings'] = $settings;
    wp_localize_script('rendez-vous-media-views', '_wpMediaViewsL10n', $strings);
    wp_enqueue_script('rendez-vous-modal');
    wp_enqueue_style('rendez-vous-modal-style');
    rendez_vous_plupload_settings();
    require_once ABSPATH . WPINC . '/media-template.php';
    add_action('admin_footer', 'wp_print_media_templates');
    add_action('wp_footer', 'wp_print_media_templates');
    do_action('rendez_vous_enqueue_editor');
}
/**
 * Output the settings section.
 *
 * @since 1.0.0
 */
function cfbgr_group_restrictions_section()
{
    $member_type = bp_get_member_type(bp_loggedin_user_id());
    $current = groups_get_groupmeta(bp_get_current_group_id(), 'cf-buddypress-group-restrictions');
    // Super Admins should be able to change the member type.. We never know..
    if (!is_super_admin() && empty($member_type)) {
        return;
    }
    // Get All member types
    $member_types = bp_get_member_types(array(), 'objects');
    if (empty($member_types)) {
        return;
    }
    $output = '<div id="group-restrictions" class="checkbox"><h4>' . esc_html__('Restrict the access to:', 'buddypress-group-restrictions') . '</h4><ul>';
    foreach ($member_types as $type_key => $type) {
        // Reset the type before each loop
        $esc_type = false;
        // If not an admin only the current user type will be displayed
        if ($member_type !== $type_key && !is_super_admin()) {
            continue;
        }
        $esc_type = esc_attr($type_key);
        $output .= sprintf('<li><label for="restriction-%s">', $esc_type);
        $output .= sprintf('<input type="checkbox" name="_cfbgr_restriction_status" id="restriction-%s" value="%s" %s/>', $esc_type, $esc_type, checked($current, $esc_type, false));
        $output .= sprintf('<strong>%s</strong></label></li>', esc_html($type->labels['singular_name']));
    }
    $output .= '<ul></div>';
    echo apply_filters('cfbgr_group_restrictions_section', $output, $member_types, $member_type);
}
        /**
         * Display a dropdown to bulk change the member type of selected user(s).
         *
         * @since 2.7.0
         *
         * @param string $which Where this dropdown is displayed - top or bottom.
         */
        public function users_table_output_type_change_select($which = 'top')
        {
            // Bail if current user cannot promote users.
            if (!bp_current_user_can('promote_users')) {
                return;
            }
            // `$which` is only passed in WordPress 4.6+. Avoid duplicating controls in earlier versions.
            static $displayed = false;
            if (version_compare(bp_get_major_wp_version(), '4.6', '<') && $displayed) {
                return;
            }
            $displayed = true;
            $id_name = 'bottom' === $which ? 'bp_change_type2' : 'bp_change_type';
            $types = bp_get_member_types(array(), 'objects');
            ?>

		<label class="screen-reader-text" for="<?php 
            echo $id_name;
            ?>
"><?php 
            _e('Change member type to&hellip;', 'buddypress');
            ?>
</label>
		<select name="<?php 
            echo $id_name;
            ?>
" id="<?php 
            echo $id_name;
            ?>
" style="display:inline-block;float:none;">
			<option value=""><?php 
            _e('Change member type to&hellip;', 'buddypress');
            ?>
</option>

			<?php 
            foreach ($types as $type) {
                ?>

				<option value="<?php 
                echo esc_attr($type->name);
                ?>
"><?php 
                echo esc_html($type->labels['singular_name']);
                ?>
</option>

			<?php 
            }
            ?>

			<option value="remove_member_type"><?php 
            _e('No Member Type', 'buddypress');
            ?>
</option>

		</select>
		<?php 
            wp_nonce_field('bp-bulk-users-change-type-' . bp_loggedin_user_id(), 'bp-bulk-users-change-type-nonce');
            submit_button(__('Change', 'buddypress'), 'button', 'bp_change_member_type', false);
        }
 /**
  * Display the selected member types per field on the Profile Fields screen
  *
  * @since 1.0.0
  *
  * @uses BP_XProfile_Field_For_Member_Types::get_xprofile_member_types()
  * @uses bp_get_meber_types()
  * @param BP_XProfile_Field $field Field object
  */
 public function admin_field_legend($field)
 {
     // Bail when the field has no member types
     if (!($member_types = $this->get_xprofile_member_types($field->id, 'field'))) {
         return;
     }
     // Get selected type labels
     $types = bp_get_member_types(array(), 'objects');
     $types = array_intersect_key($types, array_flip($member_types));
     $types = wp_list_pluck($types, 'labels');
     $types = wp_list_pluck($types, 'singular_name');
     if (in_array('none', $member_types)) {
         /* translators: 'No member type' selection */
         $types = array_merge(array(__('None', 'bp-xprofile-field-for-member-types')), $types);
     }
     // Construct legend
     $legend = sprintf(__('Member Types: %s', 'bp-xprofile-field-for-member-types'), implode(', ', $types));
     // Output legend <span>
     echo '<span class="member-types">(' . $legend . ')</span>';
 }