<?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; group</title>
	<atom:link href="http://danpolant.com/tag/group/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 Beta Release</title>
		<link>http://danpolant.com/bp-group-control-beta-release/</link>
		<comments>http://danpolant.com/bp-group-control-beta-release/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:58:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bp group control]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[group admin]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=226</guid>
		<description><![CDATA[I just finished my first Buddypress plugin, BP Group Control. It is based on a specification required by a client who will be running a Buddypress site filled with people from different companies. They wanted the group admins to be able to add and delete people directly from the site, and to assign each person [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished my first Buddypress plugin, <a href="/bp-group-control">BP Group Control</a>. It is based on a specification required by a client who will be running a Buddypress site filled with people from different companies. They wanted the group admins to be able to add and delete people directly from the site, and to assign each person a primary &#8220;identifying group.&#8221; I adapted this functionality for an open source release. I need feedback &#8211; visit the <a href="/bp-group-control">plugin homepage</a> and <a href="/bp-group-control.rar">download</a> the plugin. </p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/bp-group-control-beta-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to: create groups in Buddypress with PHP</title>
		<link>http://danpolant.com/how-to-create-groups-in-buddypress-with-php/</link>
		<comments>http://danpolant.com/how-to-create-groups-in-buddypress-with-php/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 03:26:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[group]]></category>

		<guid isPermaLink="false">http://danpolant.com/?p=40</guid>
		<description><![CDATA[Ever want to make a buddypress function that creates a group? Here&#8217;s how:
You can do this without writing any SQL. Buddypress uses a class called BP_Groups_Group to handle its group creation.  BP_Groups_Group is defined in /groups/bp-groups-classes if you want to see it.  I highly recommend taking a look at this, as you will [...]]]></description>
			<content:encoded><![CDATA[<p>Ever want to make a buddypress function that creates a group? Here&#8217;s how:</p>
<p>You can do this without writing any SQL. Buddypress uses a class called <code>BP_Groups_Group</code> to handle its group creation.  BP_Groups_Group is defined in /groups/bp-groups-classes if you want to see it.  I highly recommend taking a look at this, as you will discover other class methods that do other group-related things.</p>
<p>Say you want a plugin that upon activation creates a certain group. First add an action to the activation hook:</p>
<p><code>register_activation_hook(__file__, 'create_a_group');</code></p>
<p>Next, we need to call a function that instantiates the class BP_Groups_Group. Lets do this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> create_a_group<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$new_group</span> = BP_Groups_Group;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">creator_id</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">name</span> = <span class="st0">&#8216;test&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">slug</span> = <span class="st0">&#8216;test&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">description</span> = <span class="st0">&#8216;nothing&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">news</span> = <span class="st0">&#8216;whatever&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">status</span> = <span class="st0">&#8216;public&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">is_invitation_only</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_wire</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_forum</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_photos</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">photos_admin_only</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">date_created</span> = current_time<span class="br0">&#40;</span><span class="st0">&#8216;mysql&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">total_member_count</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">avatar_thumb</span> = <span class="st0">&#8216;some kind of path&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">avatar_full</span> = <span class="st0">&#8216;some kind of path&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$new_group</span> -&gt; <span class="me1">save</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">//this does the database insert</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>The whole point of doing it this way is so you that can use the <code>save()</code> method. Check this function out on line 90 of bp-groups-classes.php. It does all the SQL for you, and to reproduce this would be very tedious.</p>
<p><code>create_a_group()</code> will dump a row into wp_bp_groups. But if you go to your site and look at the groups directory, it won&#8217;t show up. Why? Because Buddypress checks for certain kinds of metadata before it displays a group in the main directory. So add this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> create_a_group<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$new_group</span> = <span class="kw2">new</span> BP_Groups_Group;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">creator_id</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">name</span> = <span class="st0">&#8216;test&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">slug</span> = <span class="st0">&#8216;test&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">description</span> = <span class="st0">&#8216;nothing&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">news</span> = <span class="st0">&#8216;whatever&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">status</span> = <span class="st0">&#8216;public&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">is_invitation_only</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_wire</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_forum</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">enable_photos</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">photos_admin_only</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">date_created</span> = current_time<span class="br0">&#40;</span><span class="st0">&#8216;mysql&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">total_member_count</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">avatar_thumb</span> = <span class="st0">&#8216;some kind of path&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_group</span>-&gt;<span class="me1">avatar_full</span> = <span class="st0">&#8216;some kind of path&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$new_group</span> -&gt; <span class="me1">save</span><span class="br0">&#40;</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; groups_update_groupmeta<span class="br0">&#40;</span> <span class="re0">$id</span>, <span class="st0">&#8216;total_member_count&#8217;</span>, <span class="nu0">1</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; groups_update_groupmeta<span class="br0">&#40;</span> <span class="re0">$id</span>, <span class="st0">&#8216;last_activity&#8217;</span>, <a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; groups_update_groupmeta<span class="br0">&#40;</span> <span class="re0">$id</span>, <span class="st0">&#8216;theme&#8217;</span>, <span class="st0">&#8216;buddypress&#8217;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; groups_update_groupmeta<span class="br0">&#40;</span> <span class="re0">$id</span>, <span class="st0">&#8216;stylesheet&#8217;</span>, <span class="st0">&#8216;buddypress&#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="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>This is how Buddypress updates group metadata. Your new group should show up.</p>
<p>It is worth mentioning that the other database operations in Buddypress work exactly the same way: first you instantiate a database class, populate the object with data, then you call save().  But look at the code, there are tons of other methods for these kinds of classes that will help you do things without writing redundant SQL.</p>
<p>Basically, what you are doing here mirrors what Buddypress does in step one (case 1) of <code>groups_create_group()</code> on line 1451 of bp-groups.php.  The reason you can&#8217;t just use this function is that you need your own data, not the canned query that comes with the plain old <code>populate()</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://danpolant.com/how-to-create-groups-in-buddypress-with-php/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

