Owner: David Dean
Type: WPMU Plugin
Created: 2007-09-20 13:21:38
Last Modified: 2007-09-25 14:56:36
njsl-groups.php (943 download(s))
Create arbitrary groups of users. You can restrict group creation / maintenance to site admins via switches at the top of the plugin file. Group API is a copy of the user API. As a proof of concept, provides the UI and hooks for assigning blog roles to groups. Your database user must be able to CREATE TABLE.
3 ideas: 1. search all groups 2. listing of all groups and my groups on frontend 3. each blog for group
Great idea. I'm using it to group blogs and users. I wrote some code to search groups that I thought I'd share: I pass "groupsearch=true" in the querystring to trigger it, and place this code in my index.php: $isgroupsearch=false; if ($_GET['groupsearch']=="true") { $isgroupsearch=true; } if ($isgroupsearch) { $group=$_GET['group']; global $wpdb; $query = "SELECT group_name FROM wp_groups WHERE id = " . $group; $groupnames = $wpdb->get_results($query); if ($groupnames) { foreach ($groupnames as $groupname) { echo "
Sorry, not sure that worked. Let me try posting the code again:
$isgroupsearch=false;
if ($_GET['groupsearch']=="true") { $isgroupsearch=true; }
if ($isgroupsearch)
{
$group=$_GET['group'];
global $wpdb;
$query = "SELECT group_name
FROM wp_groups
WHERE
id = " . $group;
$groupnames = $wpdb->get_results($query);
if ($groupnames) {
foreach ($groupnames as $groupname) {
echo "Blogs in " . $groupname->group_name . "
";
}
$query =
"select *
from wp_groupmeta
inner join wp_usermeta on wp_groupmeta.meta_value=wp_usermeta.user_id
inner join wp_blogs on wp_usermeta.meta_value=wp_blogs.blog_id
where wp_groupmeta.group_id=" . $group . "
and wp_usermeta.meta_key='primary_blog'
and wp_blogs.deleted=0";
$blogs = $wpdb->get_results($query);
if ($blogs) {
foreach ($blogs as $blog) {
$lastupdate=$blog->last_updated;
$blogdesc='';
$blogname='';
$siteurl='';
$query =
"select *
from wp_" . $blog->blog_id . "_options
where option_name='blogdescription'
or option_name='blogname'
or option_name='siteurl'";
$bloginfos = $wpdb->get_results($query);
if ($bloginfos) {
foreach ($bloginfos as $bloginfo) {
if ($bloginfo->option_name=='blogdescription') { $blogdesc=$bloginfo->option_value; }
if ($bloginfo->option_name=='blogname') { $blogname=$bloginfo->option_value; }
if ($bloginfo->option_name=='siteurl') { $siteurl=$bloginfo->option_value; }
}
_e($blogname)
Last updated: _e($lastupdate)
_e($blogdesc)
}
else
{
echo "Error... no blog table found for wp_" . $blog->blog_id . "_options";
}
}
}
else
{
echo "Sorry, no blogs found in " . $groupname->group_name;
}
}
else
{
echo "Sorry, this group not defined yet";
}
}
else
{ ... the rest of your post-display code goes here ("the loop") because it's a normal post and not a group search result.
Hope that makes sense and will benefit someone!You must be registered and logged in to post comments. Not registered? Click here to get your free account!