PDA

View Full Version : Featured Author: Exclude Admin


chatfan
03-11-2007, 01:02 PM
Is there a simple way to exclude the Admin from the featured author box?

Also would like to set the featured Author on weekly switch, is possible controlled or picked from a menu, not random like its now.

chatfan
03-15-2007, 02:10 AM
Nobody has a clue how to do this? Or even if it is possible?

DRIVE
06-27-2007, 06:53 AM
Not sure why the admin is an author by default. My admin hasnt written a single article, but he faithfully shows up as a featured author internittently :)

What steps to take to avoid this? The admin doesnt write any articles, ever, but he needs to manage the system because the real writers know nothing about the admin interface or any of that stuff

nfriend
06-27-2007, 11:04 AM
Maybe we should add a Featured Admin box, for all those working behind the scenes...;)
Anyway, in \class\Users.class.php at line 410 is the following function that does the selection of the random user from the database for the Featured Author box:

function FeaturedAuthor()
{
$query="SELECT userid FROM $this->db.tblUsers WHERE activated='1' AND user_type < 4 ORDER BY RAND() LIMIT 1";
$result = mysql_query($query, $this->connection) or sql_error($query, "FeaturedAuthor");
if ($row = mysql_fetch_array($result))
$this->Id = (int) $row['userid'];
}
This will take any user who is not a guest as a Featured Author. If you only want WRITERS to be featured, edit the query to user_type = 0. (BTW, ADMINS are user_type 2)
If you would like to include TRUSTED WRITERS (3), and EDITORS(1), you would need to change the query accordingly:

$query="SELECT userid FROM $this->db.tblUsers WHERE activated='1' AND user_type < 4 AND user_type != 2 ORDER BY RAND() LIMIT 1";

I did not test this code yet, and it probably could be done more elegantly, but I plan on implementing it on my site as well...

DRIVE
06-28-2007, 07:08 PM
:) we should give those working behind the scenes a BIG raise :D

I used the code below which excludes the editor, admin and includes the other 3.
Editor = 1
Admin = 2
Trusted = 3
Writer = 0
Guest = 4

function FeaturedAuthor()
{
$query="SELECT userid FROM $this->db.tblUsers WHERE activated='1' AND user_type IN ('0','3','4') ORDER BY RAND() LIMIT 1";
$result = mysql_query($query, $this->connection) or sql_error($query, "FeaturedAuthor");
if ($row = mysql_fetch_array($result))
$this->Id = (int) $row['userid'];
}

Thanks for pointing out the code block. Just fired this up a few days ago so still learning where all the goodies are :)