Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
1.9k views
in Plugins by

I always liked to know who registered as a new member in my q2a forum but could not find out how to sort users accordingly. So I wrote a little php script for this purpose. It outputs the newest members:

If you wish I can make a plugin / page out of that, just vote +1 so I can see how hot people regard this!

<?php  

    // CONNECT TO DATABASE
    require_once( 'qa-config.php' );
    mysql_connect(QA_MYSQL_HOSTNAME, QA_MYSQL_USERNAME, QA_MYSQL_PASSWORD) or die(mysql_error());
    mysql_select_db(QA_MYSQL_DATABASE) or die(mysql_error());
    
    $lastdays = 14; // users who registered last x days

    // query users
    $queryRecentUsers = mysql_query("SELECT created,handle,email,avatarblobid
                                            FROM `qa_users`
                                            WHERE created > NOW() - INTERVAL ".$lastdays." DAY
                                            ORDER BY created DESC
                                            "); // LIMIT 0,10;
    
    $users = array();
    $c = 0;    
    while($row = mysql_fetch_assoc($queryRecentUsers)) {
        $avatar = "-";
        if(!empty($row['avatarblobid'])) {
            $avatar = "<img src='http://www.
yourdomain.com/?qa=image&qa_blobid=". $row['avatarblobid'] . "&qa_size=30' />";            
        }
        // substr removes seconds
        $users[++$c] .= "<tr> <td>".substr($row['created'],0,16) . "</td> <td><a href='http://www.
yourdomain.com/user/".$row['handle']."'>" . $row['handle'] . "</a> </td> <td>" . $row['email'] . "</td> <td>".$avatar."</td></tr>";
    }

    // some html
    echo "<html><body>";
    // output all users raw
    echo "<h2>New Members within last ".$lastdays." days</h2>";
    echo "<table><thead><tr><th>RegisterTime</th> <th>Username</th> <th>E-Mail</th>  <th>Avatar</th>  </tr></thead>";
    for($i=0;$i<count($users)+1;$i++) {
        echo $users[$i];
    }
    echo '<style type="text/css">body{margin:50px;padding:0;font-family:Arial,Tahoma,Verdana,sans-serif;margin-top:40px;font-size:14px;background:#f5f5f5;color:#121212}h2{color:#006;font-weight:normal;font-size:24px;font-size:160%;padding:0;margin:0}td{border:1px solid #CCC;padding:0 .5em;line-height:25px}tr:hover{background:#ffc}table{background-color:#EEE;margin:30px 0 15px;width:800px;text-align:left;border-collapse:collapse}table thead tr th,table tfoot tr th{background-color:#cfc;border:1px solid #CCC;padding:4px}</style>';
    echo "</table> </html></body>";

?>

 

Q2A version: 1.5.3
by
moved by
Thank you, very useful
by
Good work, I was planning on doing something like this as a plugin.
by
edited by
@Scott: I am doing the plugin page right now...

Please log in or register to answer this question.

...