<?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; buddypress</title>
	<atom:link href="http://danpolant.com/tag/buddypress/feed/" rel="self" type="application/rss+xml" />
	<link>http://danpolant.com</link>
	<description></description>
	<lastBuildDate>Tue, 01 Nov 2011 03:55:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>BP Group Control hosted on WordPress.org</title>
		<link>http://danpolant.com/bp-group-control-hosted-on-wordpress-org/</link>
		<comments>http://danpolant.com/bp-group-control-hosted-on-wordpress-org/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 02:36:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bp group control]]></category>
		<category><![CDATA[buddypress]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=386</guid>
		<description><![CDATA[Wordpress.org link: <a href="http://wordpress.org/extend/plugins/bp-group-control/">http://wordpress.org/extend/plugins/bp-group-control/</a>]]></description>
			<content:encoded><![CDATA[<p>WordPress.org link: <a href="WordPress.org link: http://wordpress.org/extend/plugins/bp-group-control/">http://wordpress.org/extend/plugins/bp-group-control/</a><br/></p>
<p>Buddypress.org link: <a href="WordPress.org link: http://wordpress.org/extend/plugins/bp-group-control/">http://buddypress.org/community/groups/bp-group-control/</a></p>
<p>If you have comments and/or suggestions, I regularly check these channels as well as comments on this site.</p>
<p>Note to anyone who downloaded the plugin before a few days ago &#8211; I had named the plugin root folder wrong. You can re-download the plugin, or simply change the name of the plugin root directory from &#8220;BP-Group-Control&#8221; to &#8220;bp-group-control.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/bp-group-control-hosted-on-wordpress-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BP Group Control Usability Test</title>
		<link>http://danpolant.com/bp-group-control-usability-test/</link>
		<comments>http://danpolant.com/bp-group-control-usability-test/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 01:43:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[bp group control]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[group admin]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=379</guid>
		<description><![CDATA[I did a usability test on my new BP Group Control Plugin. Find out how it went!]]></description>
			<content:encoded><![CDATA[<p>BP Group Control is a Buddypress plugin that I built for a2im.org. Only recently was I able to update it and get it running in BP 1.2. I did this usability test pre-beta release.</p>

<p>I learn a few interesting things from this test. First, the tester got very annoyed with the lack of instant validation on the form. Turns out there is a lot you can mess up, and it tells you what you got wrong only one at a time. This will be a priority to fix in the next version.</p>
<p>This user seemed to understand what &#8220;make identifying&#8221; meant in the context, which was something that I was a bit unsure about.</p>
<p>For the most part, the tester figured out how to do what needed to be done, creating new users, adding existing users, and setting their group identifier.</p>
<p>As usual, the test exposed a few bugs that had gotten through. They&#8217;re fixed now!</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/bp-group-control-usability-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>admin</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>How to: use email addresses as usernames in Buddypress</title>
		<link>http://danpolant.com/how-to-use-email-addresses-as-usernames-in-buddypress/</link>
		<comments>http://danpolant.com/how-to-use-email-addresses-as-usernames-in-buddypress/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 01:13:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[email address]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=202</guid>
		<description><![CDATA[Just spent about 5 hours on this one, enjoy &#8230;
I&#8217;ve seen this question come up on a lot of forums &#8211; people want to use email addresses as usernames in Buddypress. It makes sense &#8211; emails are easy to remember. But Buddypress has made this difficult to do. Andy Peatling added the following constant to [...]]]></description>
			<content:encoded><![CDATA[<p>Just spent about 5 hours on this one, enjoy &#8230;</p>
<p>I&#8217;ve seen this question come up on a lot of forums &#8211; people want to use email addresses as usernames in Buddypress. It makes sense &#8211; emails are easy to remember. But Buddypress has made this difficult to do. Andy Peatling added the following constant to the core:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;BP_ENABLE_USERNAME_COMPATIBILITY_MODE&#8217;</span>, <span class="kw2">true</span> <span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>in order to deal with part of this problem. But this did not solve the problem completely. See <a href="http://codex.buddypress.org/how-to-guides/changing-internal-configuration-settings/">this article</a> for how to use this. This changed allowed users to navigate to an @-containing username&#8217;s profile, but that user could not do things like create groups or edit his profile.</p>
<p>It turns out there&#8217;s another step to getting this to work. You have to override <code>wp_sanitize_redirect</code> in wp-includes/pluggable.php and add &#8216;@&#8217; to the list of OK characters, like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> wp_sanitize_redirect<span class="br0">&#40;</span><span class="re0">$location</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="re0">$location</span> = <a href="http://www.php.net/preg_replace"><span class="kw3">preg_replace</span></a><span class="br0">&#40;</span><span class="st0">&#8216;|[^a-z0-9-~+_.?#=&amp;;,/:%!@]|i&#8217;</span>, <span class="st0">&#8221;</span>, <span class="re0">$location</span><span class="br0">&#41;</span>; <span class="co1">//this line needs to have an @</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$location</span> = wp_kses_no_null<span class="br0">&#40;</span><span class="re0">$location</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// remove %0d and %0a from location</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$strip</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;%0d&#8217;</span>, <span class="st0">&#8216;%0a&#8217;</span>, <span class="st0">&#8216;%0D&#8217;</span>, <span class="st0">&#8216;%0A&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$location</span> = _deep_replace<span class="br0">&#40;</span><span class="re0">$strip</span>, <span class="re0">$location</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$location</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Now it should work. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-use-email-addresses-as-usernames-in-buddypress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to: alter the content of activity items</title>
		<link>http://danpolant.com/how-to-alter-the-content-of-activity-items/</link>
		<comments>http://danpolant.com/how-to-alter-the-content-of-activity-items/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:58:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[filters]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=185</guid>
		<description><![CDATA[It puzzled me at first when I discovered that activity items are formatted as html before they are stored in the database. This reduces the workload upon retrieval but makes it almost impossible to edit the content of old entries.
Fortunately it is quite easy to change the way activity items are stored in the database. [...]]]></description>
			<content:encoded><![CDATA[<p>It puzzled me at first when I discovered that activity items are formatted as html before they are stored in the database. This reduces the workload upon retrieval but makes it almost impossible to edit the content of old entries.</p>
<p>Fortunately it is quite easy to change the way activity items are stored in the database. I&#8217;m going to use blog post activity items as an example, but this process is the same for just about every kind of activity item.</p>
<p>The first objective is to find the filter function that you want to hook into. For blog posts, look to line 385 of bp-blogs.php, inside function <code>bp_blogs_record_post()</code>. In general, to find these record functions, search the component core file for the string &#8216;record.&#8217; This will point you to both the utility function that hands the array off to <code>bp_activity_add()</code>, and to the function that a specific user task initiates to record an activity.</p>
<p>The filter we are interested in is bp_blogs_activity_new_post, in the segment:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">bp_blogs_record_activity<span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;user_id&#8217;</span> =&gt; <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$post</span>-&gt;<span class="me1">post_author</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;content&#8217;</span> =&gt; apply_filters<span class="br0">&#40;</span> <span class="st0">&#8216;bp_blogs_activity_new_post&#8217;</span>, <span class="re0">$activity_content</span>, &amp;amp;<span class="re0">$post</span>, <span class="re0">$post_permalink</span> <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;primary_link&#8217;</span> =&gt; apply_filters<span class="br0">&#40;</span> <span class="st0">&#8216;bp_blogs_activity_new_post_primary_link&#8217;</span>, <span class="re0">$post_permalink</span>, <span class="re0">$post_id</span> <span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;component_action&#8217;</span> =&gt; <span class="st0">&#8216;new_blog_post&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;item_id&#8217;</span> =&gt; <span class="re0">$recorded_post_id</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;recorded_time&#8217;</span> =&gt; <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span> <span class="re0">$post</span>-&gt;<span class="me1">post_date</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Now, in our plugin, or in custom.php, add the following:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">add_filter<span class="br0">&#40;</span><span class="st0">&#8216;bp_blogs_activity_new_post&#8217;</span>, <span class="st0">&#8216;my_process&#8217;</span>, <span class="nu0">2</span>, <span class="nu0">3</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> my_process<span class="br0">&#40;</span><span class="re0">$activity_content</span>, <span class="re0">$post</span>, <span class="re0">$post_permalink</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$activity_content</span> = <a href="http://www.php.net/sprintf"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span> __<span class="br0">&#40;</span> <span class="st0">&#8216;%s wrote a new blog post: %s&#8217;</span>, <span class="st0">&#8216;buddypress&#8217;</span> <span class="br0">&#41;</span>, bp_core_get_userlink<span class="br0">&#40;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$post</span>-&gt;<span class="me1">post_author</span> <span class="br0">&#41;</span>, <span class="st0">&#8216;&lt;a href=&quot;&#8217;</span> . <span class="re0">$post_permalink</span> . <span class="st0">&#8216;&quot;&gt;&#8217;</span> . <span class="re0">$post</span>-&gt;<span class="me1">post_title</span> . <span class="st0">&#8216;&lt;/a&gt;&#8217;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$activity_content</span> .= <span class="st0">&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">&lt;blockquote&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="st0">&quot;</span> . bp_create_excerpt<span class="br0">&#40;</span> <span class="re0">$post</span>-&gt;<span class="me1">post_content</span>, <span class="nu0">25</span> <span class="br0">&#41;</span> . <span class="st0">&quot;&lt;/blockquote&gt;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="st0">&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$activity_content</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<h4>Skip to the next heading if you understand filters, or don&#8217;t care!</h4>
<p>I will take a minute to explain filters, because they are a useful but somewhat obscure concept in WordPress. Filters are like actions, in that they provide an access point into code running in the WordPress framework. Filters are different from actions in that they return a value. It helps to think of <code>apply_filters()</code> as being analogous to <code>do_action()</code>. The first argument of <code>apply_filters()</code> is the tag that an <code>add_filter()</code> action hooks into with its first argument. This is not unlike the relationship between <code>add_action()</code> and <code>do_action()</code>.</p>
<p>The second to nth arguments in <code>apply_filters()</code> allow variables to be passed into your custom filter. Try and understand this diagram:</p>
<div id="attachment_187" class="wp-caption aligncenter" style="width: 514px"><img class="size-full wp-image-187 " title="wp-filters" src="http://danpolant.com/wp-content/uploads/2009/11/wp-filters.png" alt="wp-filters" width="504" height="289" /><p class="wp-caption-text">Information flow between apply_filters, add_filter, and custom filter function</p></div>
<h4>Back to the task!</h4>
<p>It would be nice if we could edit the individual components of <code>$activity_content</code>, but alas, it doesn&#8217;t have its own filter. That&#8217;s why some copying is necessary from the core file &#8211; but usually this code is pretty short, as you can see. It&#8217;s necessary to pass <code>$post, $post_permalink</code> into your filter function so that you can use these values in your activity content variable. </p>
<p>After returning the variable with your formatted feed, guess what, you&#8217;re done! <code>apply_filters()</code> will return the value of your function&#8217;s return. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-alter-the-content-of-activity-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Get Ajax working in Buddypress</title>
		<link>http://danpolant.com/how-to-get-ajax-working-in-buddypress/</link>
		<comments>http://danpolant.com/how-to-get-ajax-working-in-buddypress/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 06:17:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[buddypress]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=169</guid>
		<description><![CDATA[Ajax can really streamline a site&#8217;s user experience. The WordPress/WPMU back-end owes much of its ease of use to the presence of many dynamic menus and feedback notices. No one has had time to implement much of this for Buddypress, but I&#8217;m going to show you how to put use Ajax in your Buddypress plugins.
Its [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax can really streamline a site&#8217;s user experience. The WordPress/WPMU back-end owes much of its ease of use to the presence of many dynamic menus and feedback notices. No one has had time to implement much of this for Buddypress, but I&#8217;m going to show you how to put use Ajax in your Buddypress plugins.</p>
<p>Its not too hard, but a big barrier to getting it to work is keeping all of the connections straight. When you have something of this nature wrong it is hard to debug. </p>
<p>Lets make a button that loads a hello world via ajax. Start with whatever input fields you need, and put a <code>wp_nonce_field()</code> underneath. Its a good idea to put all of this inside a form with an action, because you want people to be able to use your plugin even if they can&#8217;t run Javascript for some silly reason!</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;form action=<span class="st0">&quot;somewhere.com/yeah&quot;</span> id=<span class="st0">&quot;my-form&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;label <span class="kw1">for</span>=<span class="st0">&quot;username&quot;</span>&gt;Name: &lt;/label&gt;&lt;input type=<span class="st0">&quot;text&quot;</span> name=<span class="st0">&quot;name&quot;</span>&gt;&lt;/input&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;label <span class="kw1">for</span>=<span class="st0">&quot;email&quot;</span>&gt;Email: &lt;/label&gt;&lt;input type=<span class="st0">&quot;text&quot;</span> name=<span class="st0">&quot;email&quot;</span>&gt;&lt;/input&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw2">&lt;?php</span> wp_nonce_field<span class="br0">&#40;</span> <span class="st0">&#8216;save&#8217;</span>, <span class="st0">&#8216;_wpnonce-save&#8217;</span> <span class="br0">&#41;</span>; <span class="kw2">?&gt;</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;input type=<span class="st0">&quot;submit&quot;</span> name=<span class="st0">&quot;save&quot;</span> id=<span class="st0">&quot;save&quot;</span> value = <span class="st0">&quot;Add this member&quot;</span>/&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;span <span class="kw2">class</span>=<span class="st0">&quot;ajax-loader&quot;</span>&gt;&lt;/span&gt; <span class="co1">//for fun, buddypress knows what this is</span></div>
</li>
<li class="li1">
<div class="de1">&lt;/form&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">Enqueue</a> a javacript file that has something like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">jQuery<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><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; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;#my-form input#save&#8217;</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><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; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;.ajax-loader&#8217;</span><span class="br0">&#41;</span>.<span class="me1">toggle</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//don&#8217;t let them click it a bunch of times in a row</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;#save&#8217;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="st0">&#8216;disabled&#8217;</span>: <span class="kw2">true</span><span class="br0">&#125;</span><span class="br0">&#41;</span>; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery.<span class="me1">post</span><span class="br0">&#40;</span> ajaxurl, <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; action: <span class="st0">&#8216;my_save&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;cookie&#8217;</span>: encodeURIComponent<span class="br0">&#40;</span>document.<span class="me1">cookie</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;_wpnonce&#8217;</span>: jQuery<span class="br0">&#40;</span><span class="st0">&quot;input#_wpnonce-save&quot;</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;username&#8217;</span>: jQuery<span class="br0">&#40;</span><span class="st0">&quot;input[name='username']&quot;</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;name&#8217;</span>: jQuery<span class="br0">&#40;</span><span class="st0">&quot;input[name='name']&quot;</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span><span class="br0">&#40;</span>response<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;.ajax-loader&#8217;</span><span class="br0">&#41;</span>.<span class="me1">toggle</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;#save&#8217;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="st0">&#8216;disabled&#8217;</span>: <span class="kw2">false</span><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;#my-form&#8217;</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span>response<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>We&#8217;re doing jQuery here. Basically this hi-jacks the submit button and causes javascript to run instead of the usual post to the action page. Read up on <a href="http://jquery.com">jQuery</a> if this code doesn&#8217;t make any sense.</p>
<p>But let me explain a few things about the <code>jQuery.post()</code>. <code>action</code>, <code>_wpnonce</code> and <code>cookie</code> are <code>$_REQUEST</code> variables that Buddypress understands &#8211; you must name these properties exactly as you see here. Additionally, their values must correspond to other values set in different places of the Ajax process. I&#8217;m going to communicate these necessary equalities in a series of rules. The first one is:</p>
<h4 style="font-style:normal;">_wpnonce&#8221; in the javascript file = id of your nonce_field (the second parameter of wp_nonce_field)</h4>
<p>Now its time to write our target php function. </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> my_save_function<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; check_ajax_referer<span class="br0">&#40;</span><span class="st0">&#8216;save&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;Sorry, I didn&#8217;t save anything&quot;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">add_action<span class="br0">&#40;</span><span class="st0">&#8216;wp_ajax_my_save&#8217;</span>, <span class="st0">&#8216;my_save_function&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Here&#8217;s the second rule:</p>
<h4 style="font-style:normal;">Bind your target function to an action named after the &#8220;action&#8221; property in your Ajax Javascript, and remember to add &#8220;wp_ajax_&#8221; to the beginning</h4>
<p>. . . And the third:</p>
<h4 style="font-style:normal;">Use the first argument (the action) of your wp_nonce_field() on the Ajax initiating template/screen function as the argument for check_admin_referer()</h4>
<p><code>check_ajax_referer</code> is a security thing &#8211; you need to do this. At the end of all of this, the message should appear dynamically at the end of your form when you press the button. Keeping the equalities straight is key.</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-get-ajax-working-in-buddypress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to: Restrict access to activity feeds</title>
		<link>http://danpolant.com/how-to-restrict-access-to-activity-feeds/</link>
		<comments>http://danpolant.com/how-to-restrict-access-to-activity-feeds/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 04:04:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=167</guid>
		<description><![CDATA[This will make it so that if some one does not have a logged in cookie, they cannot view the content of any activity feed. 



&#160;


function restrict_feeds&#40;&#41;&#123;


&#160; &#160; &#160; &#160; if &#40;!is_user_logged_in&#40;&#41;&#41; &#123;


&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; remove_action&#40; &#8216;wp&#8217;, &#8216;bp_activity_action_sitewide_feed&#8217;, 3 &#41;;


&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; remove_action&#40; &#8216;wp&#8217;, &#8216;bp_activity_action_personal_feed&#8217;, [...]]]></description>
			<content:encoded><![CDATA[<p>This will make it so that if some one does not have a logged in cookie, they cannot view the content of any activity feed. </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> restrict_feeds<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">if</span> <span class="br0">&#40;</span>!is_user_logged_in<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; &nbsp; &nbsp; &nbsp; &nbsp; remove_action<span class="br0">&#40;</span> <span class="st0">&#8216;wp&#8217;</span>, <span class="st0">&#8216;bp_activity_action_sitewide_feed&#8217;</span>, <span class="nu0">3</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remove_action<span class="br0">&#40;</span> <span class="st0">&#8216;wp&#8217;</span>, <span class="st0">&#8216;bp_activity_action_personal_feed&#8217;</span>, <span class="nu0">3</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remove_action<span class="br0">&#40;</span> <span class="st0">&#8216;wp&#8217;</span>, <span class="st0">&#8216;bp_activity_action_friends_feed&#8217;</span>, <span class="nu0">3</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</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="li2">
<div class="de2">add_action<span class="br0">&#40;</span> <span class="st0">&#8216;plugins_loaded&#8217;</span>, <span class="st0">&#8216;restrict_feeds&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>It works by removing the action that normally triggers a function that includes bp-activity-site-wide-feed.php. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-restrict-access-to-activity-feeds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BP 1.1 kills $group_obj</title>
		<link>http://danpolant.com/bp-1-1-kills-group_obj/</link>
		<comments>http://danpolant.com/bp-1-1-kills-group_obj/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 03:59:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[buddypress]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=113</guid>
		<description><![CDATA[I&#8217;ve been fixing up a few plugins for 1.1 compatibility, and have noticed that a lot of the problems center around a failure of global $group_obj. Fortunately, $bp->groups->current_group has the same information in it. What seems weird is that there is a line in the BP 1.1.1 bp-groups.php that sets $group_obj = $bp->groups->current_group. Nevertheless, I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fixing up a few plugins for 1.1 compatibility, and have noticed that a lot of the problems center around a failure of <code>global $group_obj</code>. Fortunately, <code>$bp->groups->current_group</code> has the same information in it. What seems weird is that there is a line in the BP 1.1.1 bp-groups.php that sets <code>$group_obj = $bp->groups->current_group</code>. Nevertheless, I haven&#8217;t discovered a place in either of the two plugins I&#8217;ve worked on (bpcontents and bpdev -> bpdev-groups-extra) where <code>$group_obj</code> returns anything, while <code>$bp->groups->current_group</code> seems to always work. </p>
<p>This issue was the culprit in most of the incompatibilities that I encountered. Other problems centered around the deprecated <code>bp_add_nav_item()</code>, which seemed to sometimes work but usually didn&#8217;t call the screen function correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/bp-1-1-kills-group_obj/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First look at BuddyPress 1.1</title>
		<link>http://danpolant.com/first-look-at-buddypress-1-1/</link>
		<comments>http://danpolant.com/first-look-at-buddypress-1-1/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 19:32:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[buddypress]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=102</guid>
		<description><![CDATA[I&#8217;ve been running BP 1.1 on my XAMP laptop server for a few weeks now. 1.1 has expanded admin controls, activity stream filters, and a completely revamped theme structure. 
New callback format for your screen functions
Use this instead of bp_core_add_nav_item():



bp_core_new_nav_item&#40; array&#40;&#8216;name&#8217; =&#62; __&#40;&#8216;name&#8217;, &#8216;text-domain&#8217;&#41;, &#8216;slug&#8217; =&#62; $bp-&#62;component-&#62;slug, &#8216;screen_function&#8217; =&#62; &#8216;my_screen_function&#8217;&#41;&#41;;



bp_core_new_nav_item() takes an array as its [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running BP 1.1 on my XAMP laptop server for a few weeks now. 1.1 has expanded admin controls, activity stream filters, and a completely revamped theme structure. </p>
<h4>New callback format for your screen functions</h4>
<p>Use this instead of <code>bp_core_add_nav_item()</code>:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">bp_core_new_nav_item<span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;name&#8217;</span> =&gt; __<span class="br0">&#40;</span><span class="st0">&#8216;name&#8217;</span>, <span class="st0">&#8216;text-domain&#8217;</span><span class="br0">&#41;</span>, <span class="st0">&#8216;slug&#8217;</span> =&gt; <span class="re0">$bp</span>-&gt;<span class="me1">component</span>-&gt;<span class="me1">slug</span>, <span class="st0">&#8216;screen_function&#8217;</span> =&gt; <span class="st0">&#8216;my_screen_function&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p><code>bp_core_new_nav_item()</code> takes an array as its argument, otherwise it doesn&#8217;t work. </p>
<h4>No avatars in database</h4>
<p>This one really threw me for a loop. I was bringing a plugin up to 1.1 compatibility, and it mysteriously could not load avatar_thumb or avatar_full from the database. It turns out that they got rid of these columns in <code>wp_bp_groups</code>, and now use PHP filesystem functions to load urls directly from a folder. </p>
<p>Loading an avatar is actually much simpler now. For example, if you want to load a group avatar url, just call:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">bp_core_fetch_avatar<span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;item_id&#8217;</span> =&gt; <span class="re0">$group</span>-&gt;<span class="me1">id</span>, <span class="st0">&#8216;avatar_dir&#8217;</span> =&gt; <span class="st0">&#8216;group-avatars&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>I pulled this example from a db class that takes a BP_Groups_Group object as a paramter. Any way of getting a group id here works though. And the arbitrary <code>'avatar_dir' => 'group-avatars'</code> selects the correct group avatar directory. It finds whatever folder you type in, but bp-core/bp-core-avatars.php throws on a fixed preceding path.</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/first-look-at-buddypress-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Make an element a widget sidebar</title>
		<link>http://danpolant.com/how-to-make-an-element-a-widget-sidebar/</link>
		<comments>http://danpolant.com/how-to-make-an-element-a-widget-sidebar/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 03:25:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=80</guid>
		<description><![CDATA[Widgets are a great way to let people include something cool a bunch of times in their site. The problem is, widget areas are almost always predefined in themes, and usually confined to sidebar areas. So here&#8217;s how to make any html element into a widget container.
What exactly does this mean? It means that after [...]]]></description>
			<content:encoded><![CDATA[<p>Widgets are a great way to let people include something cool a bunch of times in their site. The problem is, widget areas are almost always predefined in themes, and usually confined to sidebar areas. So here&#8217;s how to make any html element into a widget container.</p>
<p>What exactly does this mean? It means that after we&#8217;re done, you will have something on the right of your appearance->widgets screen like:</p>
<div id="attachment_81" class="wp-caption aligncenter" style="width: 189px"><img class="size-full wp-image-81" title="New widget area" src="http://danpolant.com/wp-content/uploads/2009/10/widget-backend.PNG" alt="&quot;Groups Sidebar&quot; is not a default Buddypress widget" width="179" height="85" /><p class="wp-caption-text">&quot;Groups Sidebar&quot; is not a default widget</p></div>
<h4>There&#8217;s nothing special about code that runs inside a widget.</h4>
<p> A widget is similar to any other piece of template code, except that widget output is defined by the return value of a <a href="http://codex.wordpress.org/WordPress_Widgets_Api#Developing_Widgets_on_2.8.2B">special function and class</a>. When you put your custom code into the specified parts of this function, WordPress will treat that code as something that can be run and displayed in a specific widget area, depending on where you drag your widget in /wp-admin/widgets.php.  </p>
<p>Usually you want to define a widget area in your theme file. Lets say we want to add a widget area to the groups directory page (/directories/groups/index.php) in Buddypress. First find a place where you want to put your widget area div. For my example, I&#8217;m going to make a new div in /directories/groups/index.php. You can make a new one like I&#8217;m doing, or use an existing element in the template. I&#8217;ll put my new element right about here:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=<span class="st0">&quot;sidebar&quot;</span> <span class="kw2">class</span>=<span class="st0">&quot;directory-sidebar&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">&lt;?php</span> do_action<span class="br0">&#40;</span> <span class="st0">&#8216;bp_before_directory_groups_search&#8217;</span> <span class="br0">&#41;</span> <span class="kw2">?&gt;</span>&nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=<span class="st0">&quot;groups-directory-search&quot;</span> <span class="kw2">class</span>=<span class="st0">&quot;directory-widget&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h3&gt;&lt;?php _e<span class="br0">&#40;</span> <span class="st0">&#8216;Find Groups&#8217;</span>, <span class="st0">&#8216;buddypress&#8217;</span> <span class="br0">&#41;</span> ?&gt;&lt;/h3&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">&lt;?php</span> bp_directory_groups_search_form<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">&lt;?php</span> do_action<span class="br0">&#40;</span> <span class="st0">&#8216;bp_directory_groups_search&#8217;</span> <span class="br0">&#41;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">&lt;?php</span> do_action<span class="br0">&#40;</span> <span class="st0">&#8216;bp_after_directory_groups_search&#8217;</span> <span class="br0">&#41;</span> <span class="kw2">?&gt;</span>&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=<span class="st0">&quot;groups-sidebar&quot;</span>&gt;&lt;!&#8211; my <span class="kw2">new</span> widget area will be element &#8211;&gt;</div>
</li>
</ol>
</div>
<p>This will make the area below the group search box widget friendly. Add the following lines of code underneath, like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"> &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=<span class="st0">&quot;groups-sidebar&quot;</span>&gt;&lt;!&#8211; my <span class="kw2">new</span> widget area starts here &#8211;&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">&lt;?php</span> <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;dynamic_sidebar&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; || !dynamic_sidebar<span class="br0">&#40;</span><span class="st0">&#8216;groups-sidebar&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> : <span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p><small>see <a href="http://codex.wordpress.org/WordPress_Widgets_Api/dynamic_sidebar">http://codex.wordpress.org/WordPress_Widgets_Api/dynamic_sidebar</a></small></p>
<p>Basically this is saying &#8220;if nothing has called dynamic sidebar on the element with id &#8216;groups-sidebar,&#8217; execute the code that comes after this. This is how you add default sidebar content to display when users have not added any widgets</p>
<p>There is one more step to defining a widget area. You might want to do this in a simple plugin:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">add_action<span class="br0">&#40;</span><span class="st0">&#8216;init&#8217;</span>, <span class="st0">&#8216;custom_sidebar&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> custom_sidebar<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; <span class="re0">$args</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;name&#8217;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <a href="http://www.php.net/sprintf"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span>__<span class="br0">&#40;</span><span class="st0">&#8216;Sidebar %d&#8217;</span><span class="br0">&#41;</span>, <span class="re0">$i</span> <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;id&#8217;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span class="st0">&#8216;sidebar-$i&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;before_widget&#8217;</span> =&gt; <span class="st0">&#8216;&lt;li id=<span class="es0">\&#8221;</span>%1$s<span class="es0">\&#8221;</span> class=<span class="es0">\&#8221;</span>widget %2$s<span class="es0">\&#8221;</span>&gt;&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;after_widget&#8217;</span> &nbsp;=&gt; <span class="st0">&#8216;&lt;/li&gt;&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;before_title&#8217;</span> &nbsp;=&gt; <span class="st0">&#8216;&lt;h2 class=<span class="es0">\&#8221;</span>widgettitle<span class="es0">\&#8221;</span>&gt;&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;after_title&#8217;</span> &nbsp; =&gt; <span class="st0">&#8216;&lt;/h2&gt;&#8217;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; register_sidebar<span class="br0">&#40;</span><span class="re0">$args</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p><small>source: <a href="http://codex.wordpress.org/Function_Reference/register_sidebar">http://codex.wordpress.org/Function_Reference/register_sidebar</a></small></p>
<p>You can modify these tags, but WordPress suggests that you leave the sprintf stuff alone for the sake of consistency. </p>
<h4>Your widget area should now show up in wp-admin/widgets.php</h4>
<p>It should display a properly formatted widget where ever you have it located. I found this process especially useful while editing Buddypress, because it seems like the groups and members pages should really be made widget friendly. </p>
<p>I suggest you read the documentation in <a href="http://codex.wordpress.org/WordPress_Widgets_Api">http://codex.wordpress.org/WordPress_Widgets_Api</a> for more information &#8211; this is basically how I learned to do this. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-make-an-element-a-widget-sidebar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

