MyBB Community Forums

Full Version: Exclude Usergroups
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to get an automated list that pulls from two different profile fields to exclude certain usergroups. How would I modify this to exclude usergroups 2, 3, 4, 5, 6, 7, 15, 23, 25 ?? I assume that I need to add it into the SELECT lines somehow but I'm not sure. I'd really appreciate the help with this. Smile

<?php
/**
* Author: Invidia
* Date: June 6th' 2014
* Purpose: Automates your faceclaim.
* Comments:
* Please make the changes told in the comments to make it work !
*/
 
// Please insert the access to your Database you also used during the install !
define('DBUSER', '****');
define('DBPASS', '****');
define('DBSERVER', '****');
define('DBNAME', '****');

$conn = new mysqli(DBSERVER, DBUSER, DBPASS, DBNAME);

if (!$conn) {
    die('error connecting to database');
}
 

//automated faceclaim by Invidia
 
define('IN_MYBB', 1);
require "./global.php";
require "./inc/config.php";
 
add_breadcrumb("Faceclaim", "faceclaim.php");
 
// Replace the fid[genderfid] with the fid and the ID of the Facegender profile field and the fid[namefid] with the fid and ID of the Faceclaim profile field ! For example - fid1
$faceclaim=$db->query("SELECT * FROM mybb_users LEFT JOIN mybb_userfields ON mybb_users.uid = mybb_userfields.ufid WHERE fid3 = 'female' ORDER BY mybb_userfields.fid17 ASC");
                   
                   
while($result=$db->fetch_array($faceclaim)) {
      $userid = $result['uid'];
      $username = $result['username'];
      // Replace the fid[namefid] with the fid and the ID of the Faceclaim profile field ! For example - fid2
      $avatar = $result['fid17'];
eval("\$female_faceclaim .= \"".$templates->get("female_faceclaim")."\";");   
}
 
// Replace the fid[genderfid] with the fid and the ID of the Facegender profile field and the fid[namefid] with the fid and ID of the Faceclaim profile field ! For example - fid1
$faceclaim=$db->query("SELECT * FROM mybb_users LEFT JOIN mybb_userfields ON mybb_users.uid = mybb_userfields.ufid WHERE fid3 = 'male' ORDER BY mybb_userfields.fid17 ASC");
                   
                   
while($result=$db->fetch_array($faceclaim)) {
      $userid = $result['uid'];
      $username = $result['username'];
      // Replace the fid[namefid] with the fid and the ID of the Faceclaim profile field ! For example - fid2
      $avatar = $result['fid17'];
 
eval("\$male_faceclaim .= \"".$templates->get("female_faceclaim")."\";");     
}

eval("\$faceclaim = \"".$templates->get("faceclaim")."\";");
output_page($faceclaim);
 
//automated faceclaim by Invidia
?>
You can use MySQL's "NOT IN" clause.

$faceclaim=$db->query("SELECT * FROM mybb_users LEFT JOIN mybb_userfields ON mybb_users.uid = mybb_userfields.ufid WHERE fid3 = 'female' AND mybb_users.usergroup NOT IN (2,3,4,5,6,7,15,23,25) ORDER BY mybb_userfields.fid17 ASC");

Note that this won't check additional usergroups but don't know if you need that.
That's perfect!! Thank you!