<?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>Dan Polant :: Web Interaction Designer &#187; API</title>
	<atom:link href="http://danpolant.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://danpolant.com</link>
	<description></description>
	<lastBuildDate>Fri, 04 May 2012 04:24:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to: Make sure Buddypress loads first</title>
		<link>http://danpolant.com/how-to-make-sure-buddypress-loads-first/</link>
		<comments>http://danpolant.com/how-to-make-sure-buddypress-loads-first/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 22:18:31 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[class]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=259</guid>
		<description><![CDATA[Often, it doesn&#8217;t matter whether your Buddypress plugin loads before or after Buddypress. However, if you are using groups API, or extending other Buddypress plugins, your class extensions require that Buddypress be loaded beforehand. Functions hooked into actions that occur before Buddypress loads that use Buddypress functions will cause problems as well if the load [...]]]></description>
			<content:encoded><![CDATA[<p>Often, it doesn&#8217;t matter whether your Buddypress plugin loads before or after Buddypress. However, if you are using groups API, or extending other Buddypress plugins, your class extensions require that Buddypress be loaded beforehand. Functions hooked into actions that occur before Buddypress loads that use Buddypress functions will cause problems as well if the load order is wrong.</p>
<p>WordPress loads plugins in alphabetical order. So the simplest (and most janky) solution is to name your plugin something that comes after &#8220;buddypress&#8221; in the alphabet. But there are better methods that you should use instead.</p>
<h4>For versions before BP 1.2</h4>
<p>The goal here is to check whether Buddypress has been loaded at the point when your plugin loads, and if it has not, load it manually. The manual load will prevent the normal load from happening later, so you won&#8217;t get double what you need.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">//hack required to load BP first</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> bpgc_load_buddypress<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//buddypress is loaded</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/function_exists"><span class="kw3">function_exists</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;bp_core_setup_globals&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Get the list of active sitewide plugins </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$active_sitewide_plugins</span> = maybe_unserialize<span class="br0">&#40;</span> get_site_option<span class="br0">&#40;</span> <span class="st0">&#8216;active_sitewide_plugins&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$bp_activated</span> = <span class="re0">$active_sitewide_plugins</span><span class="br0">&#91;</span><span class="st0">&#8216;buddypress/bp-loader.php&#8217;</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//bp is not activated</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<span class="re0">$bp_activated</span> <span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//bp is activated but not yet loaded</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$bp_activated</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//load bp if its not activated</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">if</span> <span class="br0">&#40;</span> bpgc_load_buddypress<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">require_once</span><span class="br0">&#40;</span> WP_PLUGIN_DIR . <span class="st0">&#8216;/buddypress/bp-loader.php&#8217;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<h4>If you are using BP 1.2+</h4>
<p>Fortunately, they made this much easier to do in BP 1.2. For my plugin, all I needed to do was:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> bpgc_bp_loaded<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">require</span> <span class="br0">&#40;</span> WP_PLUGIN_DIR . <span class="st0">&quot;/BP-Group-Control/bpgc-classes.php&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">add_action<span class="br0">&#40;</span><span class="st0">&#8216;bp_init&#8217;</span>, <span class="st0">&#8216;bpgc_bp_loaded&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>&#8230; in order to load my classes only once Buddypress has finished loading. Probably the safest way to ensure that your plugin completely loads after Buddypress is to create a loader.php file that contains this action and loads all of your other files. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-make-sure-buddypress-loads-first/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buddypress API</title>
		<link>http://danpolant.com/buddypress-api/</link>
		<comments>http://danpolant.com/buddypress-api/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 07:45:31 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[buddypress]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=32</guid>
		<description><![CDATA[Function Name:
groups_update_groupmeta ($id, $meta_key, $meta_value)
Parameters:
$id: a group id
$meta_key: name of the metadatum you want to set
$meta_value: the value you want to give it
Function Name:
xprofile_set_field_data($field_key, $id, $field_val)
Sets the value of an extended profile field
Parameters:
$field_key: Name of the field you want to set
$id: a user id
$field_val: Value of the field to be set
]]></description>
			<content:encoded><![CDATA[<p>Function Name:</p>
<p><code>groups_update_groupmeta ($id, $meta_key, $meta_value)</code></p>
<p>Parameters:</p>
<p>$id: a group id<br />
$meta_key: name of the metadatum you want to set<br />
$meta_value: the value you want to give it</p>
<p>Function Name:</p>
<p><code>xprofile_set_field_data($field_key, $id, $field_val)</code></p>
<p>Sets the value of an extended profile field</p>
<p>Parameters:</p>
<p>$field_key: Name of the field you want to set<br />
$id: a user id<br />
$field_val: Value of the field to be set</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/buddypress-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

