BP_XProfile_Group::fetch_default_visibility_levels()

Fetch the admin-set preferences for all fields.


Return Return

(array) $default_visibility_levels An array, keyed by field_id, of default visibility level + allow_custom (whether the admin allows this field to be set by user)


Source Source

File: bp-xprofile/classes/class-bp-xprofile-group.php

	public static function fetch_default_visibility_levels() {
		global $wpdb;

		$default_visibility_levels = wp_cache_get( 'default_visibility_levels', 'bp_xprofile' );

		if ( false === $default_visibility_levels ) {
			$bp = buddypress();

			$levels = $wpdb->get_results( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" );

			// Arrange so that the field id is the key and the visibility level the value.
			$default_visibility_levels = array();
			foreach ( $levels as $level ) {
				switch ( $level->meta_key ) {
					case 'default_visibility' :
						$default_visibility_levels[ $level->object_id ]['default']      = $level->meta_value;
						break;
					case 'allow_custom_visibility' :
						$default_visibility_levels[ $level->object_id ]['allow_custom'] = $level->meta_value;
						break;
				}
			}

			wp_cache_set( 'default_visibility_levels', $default_visibility_levels, 'bp_xprofile' );
		}

		return $default_visibility_levels;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.