bp_core_install_extended_profiles()
Install database tables for the Profiles component.
Description Description
Source Source
File: bp-core/admin/bp-core-admin-schema.php
function bp_core_install_extended_profiles() { global $wpdb; $sql = array(); $charset_collate = $GLOBALS['wpdb']->get_charset_collate(); $bp_prefix = bp_core_get_table_prefix(); // These values should only be updated if they are not already present. if ( ! bp_get_option( 'bp-xprofile-base-group-name' ) ) { bp_update_option( 'bp-xprofile-base-group-name', _x( 'General', 'First field-group name', 'buddypress' ) ); } if ( ! bp_get_option( 'bp-xprofile-fullname-field-name' ) ) { bp_update_option( 'bp-xprofile-fullname-field-name', _x( 'Display Name', 'Display name field', 'buddypress' ) ); } $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(150) NOT NULL, description mediumtext NOT NULL, group_order bigint(20) NOT NULL DEFAULT '0', can_delete tinyint(1) NOT NULL, KEY can_delete (can_delete) ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, group_id bigint(20) unsigned NOT NULL, parent_id bigint(20) unsigned NOT NULL, type varchar(150) NOT NULL, name varchar(150) NOT NULL, description longtext NOT NULL, is_required tinyint(1) NOT NULL DEFAULT '0', is_default_option tinyint(1) NOT NULL DEFAULT '0', field_order bigint(20) NOT NULL DEFAULT '0', option_order bigint(20) NOT NULL DEFAULT '0', order_by varchar(15) NOT NULL DEFAULT '', can_delete tinyint(1) NOT NULL DEFAULT '1', KEY group_id (group_id), KEY parent_id (parent_id), KEY field_order (field_order), KEY can_delete (can_delete), KEY is_required (is_required) ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, field_id bigint(20) unsigned NOT NULL, user_id bigint(20) unsigned NOT NULL, value longtext NOT NULL, last_updated datetime NOT NULL, KEY field_id (field_id), KEY user_id (user_id) ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta ( id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, object_id bigint(20) NOT NULL, object_type varchar(150) NOT NULL, meta_key varchar(255) DEFAULT NULL, meta_value longtext DEFAULT NULL, KEY object_id (object_id), KEY meta_key (meta_key(191)) ) {$charset_collate};"; dbDelta( $sql ); // Insert the default group and fields. $insert_sql = array(); if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1" ) ) { $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );"; } if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) { $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );"; // Make sure the custom visibility is disabled for the default field. if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) { $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );"; } } dbDelta( $insert_sql ); }
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |