bp_update_to_8_0()

8.0.0 update routine.


Description Description

  • Edit the new_avatar activity type’s component to members.
  • Upgrade Primary xProfile Group’s fields to signup fields.

Source Source

File: bp-core/bp-core-update.php

function bp_update_to_8_0() {
	global $wpdb;
	$bp_prefix = bp_core_get_table_prefix();

	// Install welcome email to email list.
	add_filter( 'bp_email_get_schema', 'bp_core_get_8_0_upgrade_email_schema' );

	bp_core_install_emails();

	remove_filter( 'bp_email_get_schema', 'bp_core_get_8_0_upgrade_email_schema' );

	// Update the `new_avatar` activity type's component to `members`.
	$wpdb->update(
		$bp_prefix . 'bp_activity',
		array(
			'component' => 'members',
		),
		array(
			'type' => 'new_avatar',
		),
		array(
			'%s',
		),
		array(
			'%s',
		)
	);

	// Check if we need to create default signup fields.
	$field_id            = bp_get_fullname_field_id_for_update();
	$has_signup_position = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$bp_prefix}bp_xprofile_meta WHERE meta_key = 'signup_position' AND object_type = 'field' AND object_id = %d", $field_id ) );
	if ( bp_get_signup_allowed() && ! $has_signup_position ) {
		// Get the Primary Group's fields.
		$signup_fields = $wpdb->get_col( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE group_id = 1 ORDER BY field_order ASC" );

		// Migrate potential signup fields.
		if ( $signup_fields ) {
			$signup_position = 0;
			foreach ( $signup_fields as $signup_field_id ) {
				$signup_position += 1;

				$wpdb->insert(
					$bp_prefix . 'bp_xprofile_meta',
					array(
						'object_id'   => $signup_field_id,
						'object_type' => 'field',
						'meta_key'    => 'signup_position',
						'meta_value'  => $signup_position,
					),
					array(
						'%d',
						'%s',
						'%s',
						'%d',
					)
				);
			}
		}
	}

	bp_core_install_nonmember_opt_outs();
}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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