bp_get_user_social_networks_urls( $user_id = null )

Add social networks button to the member header area.

Description

Return

(string)

Source

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

function bp_get_user_social_networks_urls() {

	global $wpdb;

	$social_networks_id = (int) $wpdb->get_var( "SELECT a.id FROM {$wpdb->prefix}bp_xprofile_fields a WHERE parent_id = 0 AND type = 'socialnetworks' ");

	$html = '';
	$original_option_values = array();
	if ( $social_networks_id > 0 ) {
		$providers = social_network_provider();
		$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $social_networks_id, bp_displayed_user_id() ) );

		if ( isset( $original_option_values ) && !empty( $original_option_values ) ) {
			foreach ( $original_option_values as $key => $original_option_value ) {
				if ( '' !== $original_option_value ) {
					$key  = bp_social_network_search_key( $key, $providers );
					$html .= '<span class="social ' . $providers[ $key ]->value . '"><a target="_blank" data-balloon-pos="up" data-balloon="' . $providers[ $key ]->name . '" href="' . esc_url( $original_option_value ) . '">' . $providers[ $key ]->svg . '</a></span>';
				}
			}
		}
	} else {
		$html = '';
	}

	if ( '' !== $html ) {

		$level = xprofile_get_field_visibility_level( $social_networks_id, bp_displayed_user_id() );

		if ( bp_displayed_user_id() === bp_loggedin_user_id() ) {
			$html = '<div class="social-networks-wrap">'.$html.'</div>';
		} elseif ( 'public' === $level ) {
			$html = '<div class="social-networks-wrap">'.$html.'</div>';
		} elseif ( 'loggedin' === $level && is_user_logged_in() ) {
			$html = '<div class="social-networks-wrap">'.$html.'</div>';
		} elseif ( 'friends' === $level && is_user_logged_in() ) {
			$member_friend_status = friends_check_friendship_status( bp_loggedin_user_id(), bp_displayed_user_id() );
			if ( 'is_friend' === $member_friend_status ) {
				$html = '<div class="social-networks-wrap">' . $html . '</div>';
			} else {
				$html = '';
			}
		}

	}

	return apply_filters( 'bp_get_user_social_networks_urls', $html, $original_option_values, $social_networks_id );
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 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.