bp_infusion_soft_sync_bp_data( $user_id )

Sync the BP data based on the WP data via infusion soft API.

Description

Parameters

$user_id

(Required)

Source

File: bp-members/bp-members-functions.php

function bp_infusion_soft_sync_bp_data( $user_id ) {

	if ( function_exists('iMember360') ) {

		$first_name_id = (int) get_option( 'bp-xprofile-firstname-field-id' );
		$nickname_id   = (int) get_option( 'bp-xprofile-nickname-field-id' );
		$last_name_id  = (int) get_option( 'bp-xprofile-lastname-field-id' );

		$xprofile_nick_name  = xprofile_get_field_data( $nickname_id, $user_id );
		$xprofile_first_name = xprofile_get_field_data( $first_name_id, $user_id );
		$xprofile_last_name  = xprofile_get_field_data( $last_name_id, $user_id );

		if ( '' === $xprofile_first_name ) {
			$result_first_name = get_user_meta( $user_id, 'first_name', true );
			if ( empty( $result_first_name ) ) {
				$result_first_name = get_user_meta( $user_id, 'nickname', true );
			}
			xprofile_set_field_data( $first_name_id, $user_id, $result_first_name );
		}

		if ( '' === trim( $xprofile_nick_name ) ) {
			$user = get_userdata( $user_id );
			// make sure nickname is valid
			$nickname = get_user_meta( $user_id, 'nickname', true );
			$nickname = sanitize_title( $nickname );
			$invalid  = bp_xprofile_validate_nickname_value( '', $nickname_id, $nickname, $user_id );

			// or use the user_nicename
			if ( ! $nickname || $invalid ) {
				$nickname = $user->user_nicename;
			}
			xprofile_set_field_data( $nickname_id, $user_id, $nickname );
		}

		if ( '' === $xprofile_last_name ) {
			$result_last_name = get_user_meta( $user_id, 'last_name', true );
			xprofile_set_field_data( $last_name_id, $user_id, $result_last_name );
		}

	}

}

Changelog

Changelog
Version Description
BuddyBoss 1.1.5 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.