<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>&#60;Code Zen /&#62; &#187; plugins</title>
	<atom:link href="http://www.code-zen.net/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.code-zen.net</link>
	<description>Peter Anselmo&#039;s Home on the Web</description>
	<lastBuildDate>Thu, 17 Jun 2010 15:16:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Custom Profile Field Data in Buddypress Templates</title>
		<link>http://www.code-zen.net/2009/using-custom-profile-field-data-in-buddypress-templates/</link>
		<comments>http://www.code-zen.net/2009/using-custom-profile-field-data-in-buddypress-templates/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 22:48:14 +0000</pubDate>
		<dc:creator>Peter Anselmo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.code-zen.net/?p=325</guid>
		<description><![CDATA[I ran into what I thought would be fairly common need for Buddypress theme development, the ability to pull data from a custom user profile field and display it.  After searching a bit, I could only find way to pull either random fields, or all of the fields together.  So after digging around [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into what I thought would be fairly common need for Buddypress theme development, the ability to pull data from a custom user profile field and display it.  After searching a bit, I could only find way to pull either random fields, or all of the fields together.  So after digging around in the core files, I found the pieces to put together my own function for the task.</p>
<p>1. <strong>Create the file &#8220;bp-custom.php&#8221;</strong> and place it directly in the plugins folder.  Note, do not place it in the &#8220;buddypress&#8221; folder, otherwise it will be overwritten when upgrading.  If the file exists, simply append to it rather than creating a new one.</p>
<p>2. <strong>Paste the following function</strong> in:</p>
<pre>function bp_the_site_member_profile_data($field_name = '', $echo = 1) {
  if( !$field_name ) {
    return false;
  }
  global $site_members_template;
  if( function_exists( 'xprofile_get_field_data' ) ) {
    $data = xprofile_get_field_data( $field_name,
                                     $site_members_template-&gt;member-&gt;id);
    if( $echo ) {
      echo "<span class="single-field-data">$data</span>";
      return true;
    } else {
      return $data;
    }
  }
}</pre>
<p>3. You can now <strong>use the function &#8216;bp_the_site_member_profile_data(&#8216;MyField&#8217;)</strong> in your templates (of course, substituting &#8216;MyField&#8217; with the one you&#8217;d like to use).  Note, this must be place inside a &#8216;Members Loop&#8217; so that the $site_members_template variable is populated.  Odds are, you&#8217;re inserting this near other profile data already in the loop, so there should be no problems.</p>
<p>UPDATE:<br />
As of BuddyPress 1.2, this functionality has been included.  While in the members loop, you can use the included function: &#8216;bp_member_profile_data( &#8216;field=the field name&#8217; )&#8217; to much the same effect.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;headline=Using+Custom+Profile+Field+Data+in+Buddypress+Templates"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;u=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates&amp;summary=&amp;source="><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/reader/link?url=http%3A%2F%2Fwww.code-zen.net%2F2009%2Fusing-custom-profile-field-data-in-buddypress-templates%2F&amp;title=Using+Custom+Profile+Field+Data+in+Buddypress+Templates"><img class="lightsocial_img" src="http://www.code-zen.net/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.code-zen.net/2009/using-custom-profile-field-data-in-buddypress-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
