Skip to content

Instantly share code, notes, and snippets.

@8lane
Created December 27, 2013 20:45
Show Gist options
  • Save 8lane/8152412 to your computer and use it in GitHub Desktop.
Save 8lane/8152412 to your computer and use it in GitHub Desktop.
Wordpress Multisite + Groups Plugin: Check if user is in group
<?php
$blog_id = 1; //set the blog id to the main site id
switch_to_blog( $blog_id );
$user_id = get_current_user_id();
$group = Groups_Group::read_by_name( 'Premium' );
if ( Groups_User_Group::read( $user_id, $group->group_id ) ) {
echo 'Premium';
} else {
echo 'Not premium';
}
restore_current_blog();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment