MyBB Community Forums

Full Version: SQL Query Questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
1. How can I change the usergroup of everyone with 0 posts to "Awaiting Activation"?

2. How can I export a list of all activated users with their usernames and email addresses attached? (Importing into MailChimp)

Thanks!
From the console, you can type:

SELECT gid FROM mybb_usergroups WHERE title = 'Awaiting Activation';

to find out the group id of the "Awaiting Activation" group. Then you'll want to change all users with a post count < 1. So, if the first statement resulted in "5" being the group id, then you would type the following to change all users with a post count less < 1 to group 5:

UPDATE mybb_users SET usergroup = 5 WHERE postnum < 1;

[edit] As for exporting, I dunno. Sorry.
see replies here for the second requirement

<?php
define("IN_MYBB",1);
include("global.php");
$result = $db->query("SELECT * FROM ".TABLE_PREFIX."users");
$tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
while ($row = $db->fetch_array($result, MYSQLI_NUM)) {
echo $row['uid'], $tab, $row['username'], $tab, $row['email']."<br />";
}
?>
Thanks both for your answers.
Another one – how to filter based on time spent online, with more than x minutes?