Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Social Icons Profiles BP

@sandyfischler

Participant

@amic58 I think the code referenced above doesn’t work with WP 4. I have it partly working now but I still have text links instead of icons that link. Help I’ve gotten elsewhere indicates that xprofile_get_field_data() works differently in the current version of WP. I’ve tested in both my child theme and TwentyFourteen and get the same result, so I’m sure it has something to do with the current version of WP and not the theme.

Anyway, here is where I’m at now with trying to make this work (I have this code in a file called bp-custom.php that sits in my root Plugins folder). I used the code sample I found here:
https://buddypress.org/support/topic/display-users-social-follow-buttons-in-profile/

<?php
//Social Media Icons based on the profile user info
function member_social_extend(){
		$dmember_id = $bp->displayed_user->id;
		$fb_info = xprofile_get_field_data('facebook', $dmember_id);
		$google_info = xprofile_get_field_data('googleplus', $dmember_id);
		$linkedin_info = xprofile_get_field_data('linkedin', $dmember_id);
		$twitter_info = xprofile_get_field_data('twitter', $dmember_id);
		echo '<div class="member-social">';
		if($fb_info||$google_info||$linkedin_info||$twitter_info){
			echo 'My Social: ';
		}

		if ($fb_info) {
		?>
		<span class="fb-info"><?php echo $fb_info; ?>" title="My Facebook" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/facebook.png" /></span>
	<?php
	}
		?>
		<?php
		if ($google_info) {
		?>
		<span class="google-info"><?php echo $google_info; ?>" title="My Googleplus" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/googleplus.png" /></span>
	<?php
	}
		?>
		<?php
		if ($linkedin_info) {
		?>
		<span class="linkedin-info"><?php echo $linkedin_info; ?>" title="My LinkedIn" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/linkedin.png" /></span>
	<?php
	}
		?>
		<?php
		if ($twitter_info) {
		?>
		<span class="twitter-info"><?php echo $twitter_info; ?>" title="My Twitter" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/twitter.png" /></span>
	<?php
	}
	echo '</div>';
}
add_filter( 'bp_before_member_header_meta', 'member_social_extend' );
?>

I have been adjusting this as new information comes in. One thing that seems wrong to me is putting the social icons in a theme dependent folder. If the point is to have this work with ANY theme, those image files need to live in more static location.

When I figure out more I’ll post here (hopefully later today).

Skip to toolbar