I took over a WP site that was developed by another person. They created a custom function in functions.php named wp_authors_directory (see code below). They then created a page template to display the results of the function (see code below).
The problem is, it appears to me as though the function is designed to exclude the admin from the directory, but the admin is not being excluded. Both the user name and the nickname of the admin are "admin" but it is still not being excluded. Can someone help?
Here is a link to the directory page where the results are rendered, admin is displaying at the top:
http://networkoftacoma.com/member-directory/
Very much appreciated!
functions.php code:
function wp_authors_directory($args = '') {
global $wpdb;
$my_base = get_bloginfo('url');
$defaults = array(
'optioncount' => false, 'exclude_admin' => true,
'show_fullname' => true, 'hide_empty' => false,
'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true
);
$r = wp_parse_args( $args, $defaults );
extract($r, EXTR_SKIP);
/** @todo Move select to get_authors(). */
// $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
$authors = $wpdb->get_results("SELECT ID, user_login, meta_key, meta_value from {$wpdb->users} LEFT JOIN {$wpdb->usermeta} ON {$wpdb->usermeta}.user_id = {$wpdb->users}.ID WHERE {$wpdb->users}.user_login NOT LIKE 'unverified%' AND meta_key LIKE 'last_name' ORDER BY meta_value");
foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->ID );
$name = "$author->first_name $author->last_name";
$image = $author->userphoto_thumb_file;
$image_width = $author->userphoto_thumb_width;
$image_height = $author->userphoto_thumb_height;
$company = $author->company;
$category = $author->business_category;
$network_role = $author->network_of_tacoma_role;
$phone = $author->phone;
$fax = $author->fax;
$email = $author->user_email;
$website = $author->user_url;
$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Details About %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
if ($website == null ) {
$website = 'mailto:' . $email;
}
if ($image == null ) {
$image = 'no_photo.gif';
}
echo '<div class="member clearfix">
<div class="member-thumb">
<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Details About %s"), attribute_escape($author->display_name)) . '"><img src="' . $base . '/wp-content/uploads/userphoto/' . $image .'" width="' . $image_width . '" height="' . $image_height . '" alt="' . $name . '" /></a>
</div>
<div class="member-details">
<h3>' . $link . '</h3
<dl class="clearfix">
<dt>Company</dt>
<dd><a href="' . $website . '" target="_blank">' . $company . '</a></dd>
</dl>
<dl class="clearfix">
<dt>Business Category</dt>
<dd><a href="' . $website . '" target="_blank">' . $category . '</a></dd>
</dl>
<dl class="clearfix">
<dt>Network Role</dt>
<dd>' . $network_role . '</dd>
</dl>
<dl class="clearfix">
<dt>Phone</dt>
<dd>' . $phone . '</dd>
</dl>
<dl class="clearfix">
<dt>Email</dt>
<dd><a href="mailto:' . $email . '">' . $email . '</a></dd>
</dl>
<p><em>More about ' . $link . '</em></p>
</div>
</div>'
;
}
}
Directory page template code:
<?php
/*
Template Name: Directory Template
*/
?>
<?php get_header(); ?>
<div class="left-column">
<?php include('side-main.php'); ?>
</div>
<div class="right-column">
<?php wp_authors_directory(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>