This is an old version of this answer!
Return to the current answerMethod I. SPECIAL PAGE TEMPLATE
Create a template for a special page in your theme directory (for ward.php file):
Create a page that uses this template (for example /wardpage/).
You can now display your list like that:
http://your.site.com/wardpage/?ward=northgate&electedmember=citycouncillor
In .htaccess you can define a simpler link for this adding a line just after RewriteEngine On:
RewriteRule ^wardpage/(.+)/(.+) index.php/wardpage/?ward=$1&electedmember=$2 [L]
And then use urls like that:
http://your.site.com/wardpage/northgate/citycouncillor
You will probably need to add get_sidebar() somewhere depending on the theme you are using - you can use page.php in your template as a pattern.
I hope I didn't make any mistake. :)
Method II. AS A PLUGIN
1. Create an empty page "ward" (or anything you like)
2. Create a folder wardplugin in wp-content/plugins
3. create index.php in the folder:
4. Activate the plugin.
I didn't test the plugin version, so it could have some bugs.
Create a template for a special page in your theme directory (for ward.php file):
<?php
/*
Template Name: Ward Page
*/
get_header();
// here display your list, you will probably have to close it
// with <div id="wrapper"> or something, depending on your theme
global $wpdb;
$ward = $wpdb->escape($_GET['ward']);
$electedmember = $wpdb->escape($_GET['electedmember']);
$q = "SELECT ID FROM wp_users u, wp_usermeta m1, wp_usermeta m2 WHERE u.ID = m1.user_id AND u.ID = m2.user_id AND m1.meta_key = 'ward' AND m1.meta_value = '$ward' AND m2.meta_key = 'electedmember' AND m2.meta_value = '$electedmember' ";
$res = $wpdb->get_results($q);
if($res)
{
echo "<ul>";
foreach($res as $uid)
{
$userid = $uid->ID;
$user_info = get_userdata($userid);
echo "<li>";
echo $user_info->user_login;
echo "</li>";
}
echo "</ul>";
}
get_footer();
Create a page that uses this template (for example /wardpage/).
You can now display your list like that:
http://your.site.com/wardpage/?ward=northgate&electedmember=citycouncillor
In .htaccess you can define a simpler link for this adding a line just after RewriteEngine On:
RewriteRule ^wardpage/(.+)/(.+) index.php/wardpage/?ward=$1&electedmember=$2 [L]
And then use urls like that:
http://your.site.com/wardpage/northgate/citycouncillor
You will probably need to add get_sidebar() somewhere depending on the theme you are using - you can use page.php in your template as a pattern.
I hope I didn't make any mistake. :)
Method II. AS A PLUGIN
1. Create an empty page "ward" (or anything you like)
2. Create a folder wardplugin in wp-content/plugins
3. create index.php in the folder:
<?php
/**
* @package WardPlugin
* @author Tomasz Kucza
* @version 1.0.0
*/
/*
Plugin Name: WardPlugin
Plugin URI: http://magory.net/
Description: A plugin for displaying user lists with special usermeta
Author: Tomasz Kucza
Version: 1.0.0
Author URI: http://magory.net
*/
add_filter('the_content', 'wardUsers');
function wardUsers($content)
{
global $wpdb, $post;
if($post->post_name != 'ward') // change it if your page has different post_name
return $content;
$ward = $wpdb->escape($_GET['ward']);
$electedmember = $wpdb->escape($_GET['electedmember']);
$q = "SELECT ID FROM wp_users u, wp_usermeta m1, wp_usermeta m2 WHERE u.ID = m1.user_id AND u.ID = m2.user_id AND m1.meta_key = 'ward' AND m1.meta_value = '$ward' AND m2.meta_key = 'electedmember' AND m2.meta_value = '$electedmember' ";
$res = $wpdb->get_results($q);
if($res)
{
$content.="<ul>";
foreach($res as $uid)
{
$userid = $uid->ID;
$user_info = get_userdata($userid);
$content.="<li>";
$content.=$user_info->user_login;
$content.="</li>";
}
$content.="</ul>";
}
return $content;
}
4. Activate the plugin.
I didn't test the plugin version, so it could have some bugs.
MagoryNET | 08/19/10 at 5:55pm





