A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
List of members in specific group
Mar 9, 2010
8:52 am
Member
Forum Posts: 147
Member Since:
Nov 1, 2009
Offline

Hi! I would like to view a list of members within a given spf group on a wp page (for instance above the widgets in a sidebar). Couldn't find a template tag to do this… basically the code would go something like:

<ul><?php foreach(member in a group) {echo: '<li><a href=" ' .link-to-profile. ' ">' .member avatar. ' '. member-name .'</a></li>';} ?> </ul>

Any thoughts, anyone?

Mar 9, 2010
2:55 pm

SP Master
Forum Posts: 22131
Member Since:
Nov 9, 2008
Offline

Take a look at the code in the file:
simple-forum/admin/pane-usergroups/ahah/sfa-ahah-usergroups.php
his is basically what that code does. it is the code that populates the 'show users' on the usergroups forum.

Yellow Swordfish
Mar 9, 2010
2:58 pm
Member
Forum Posts: 147
Member Since:
Nov 1, 2009
Offline

thanks! on another note.. could there be something wrong with the "Keep Forum and WP Display Name In Sync:" setting in the profiles? The sync seems to only go one way – When the profile in wp-profile is changed, it automatically updates the forum profile, but when I update the forum profile, it doesn't automatically update the wp profile… And also – how would you go about making the "Keep Forum and WP Display Name In Sync:" setting to "On" as default for new members?

Mar 9, 2010
3:10 pm
Member
Forum Posts: 147
Member Since:
Nov 1, 2009
Offline

Oh hmm. I took a look at that file – and I am not that proficient in php… is it something there that could be copied to a wp page template..?

Mar 9, 2010
3:44 pm

SP Master
Forum Posts: 22131
Member Since:
Nov 9, 2008
Offline

Well no – not as is. Sorry – I thought you wanted to code something and this is a good template to work from as it basically does what you want. But it would need some recoding to work outside of the forum.

Yellow Swordfish
Mar 10, 2010
4:55 am
Member
Forum Posts: 147
Member Since:
Nov 1, 2009
Offline

Yey… I actually managed it.. with your help and a little help from the code in the plugin "Author Avatars List"

If you're interested – here is the code:

 

function memberlist(){
// Function to display a list of members in certain spf user groups 
// on certain wp-pages with their avatars and links to their profiles.
// Define how to display output
function ph_sfa_display_member_roll($members) {
$out.= '<div class="ph-author-avatars">';
$out.= '<div class="author-list">';
$out.= '<div class="sidebar">';
$out.= '<h3>Medlemmer</h3>';
$out.= '</div>';
if ($members) {
for ($x=0; $x<count($members); $x++) {
$out.= '<div class="user"><a href="'.sf_build_profile_formlink($members[$x]->user_id).'"><span class="avatar">'.get_avatar($members[$x]->user_id, 60).'</span><span class="name"><strong>'.sf_filter_name_display($members[$x]->display_name).'</strong></span></a><div class="biography">'.get_the_author_meta('description', $members[$x]->user_id).'</div></div>';
}
} else {
$out.=  'Ingen medlemmer funnet… På tide å registrere seg?';
}
$out.= '</div>';
$out.= '</div>';
return $out;
}
// Define which page belongs to which user group
if(is_page('stv')) $usergroup_id = 11;
if(is_page('fu')) $usergroup_id = 7;
if(is_page('alu')) $usergroup_id = 8;
if(is_page('sr')) $usergroup_id = 10;
if(is_page('iapss')) $usergroup_id = 14;
if(is_page('ifis')) $usergroup_id = 12;
if(is_page('zp')) $usergroup_id = 13;
if(is_page('mf')) $usergroup_id = 9;
// Collect data from spf database tables
if($usergroup_id) {
global $wpdb;
$sql = "SELECT ".SFMEMBERSHIPS.".user_id, display_name
FROM ".SFMEMBERSHIPS."
JOIN ".SFMEMBERS." ON ".SFMEMBERS.".user_id = ".SFMEMBERSHIPS.".user_id
WHERE ".SFMEMBERSHIPS.".usergroup_id=".$usergroup_id."
ORDER BY display_name";
$members = $wpdb->get_results($sql);
echo ph_sfa_display_member_roll($members);
}
}
// For use with the Thesis theme:
add_action('thesis_hook_before_sidebars', 'memberlist');
And here is the corresponding css:

.custom .ph-author-avatars div.author-list { padding:0 0 0 1em; width:40em; }
.custom .ph-author-avatars div.author-list h3{ font-size:1.4em; }
.custom .ph-author-avatars div.author-list .user { float:left; display: block; padding:0.2em; width:19em; text-align:left; }
.custom .ph-author-avatars div.author-list .user span.name{ display:block; font-size:1.1em; }
.custom .ph-author-avatars div.author-list .user div.biography { font-size:0.95em; }
.custom .ph-author-avatars div.author-list .user a{ /*text-decoration:none;*/ }
.custom .ph-author-avatars div.author-list .user .avatar img{ float:left; margin:0 1em 1em 0; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius:4px; }
See the result here: http://statsvitenskap.no/foreninger/fu/ (and the other "foreninger"-pages – these are different student associations)

 

Mar 10, 2010
5:18 am

SP Master
Forum Posts: 22131
Member Since:
Nov 9, 2008
Offline

Very nice. You did well.
I'll take a closer look at the code you used…
Thanks for sharing.

Yellow Swordfish
Mar 10, 2010
5:20 am
Member
Forum Posts: 147
Member Since:
Nov 1, 2009
Offline

Cool.. any suggestions to make it cleaner are deeply welcome!

PS.. I tried using the avatar template tag:

sf_show_members_avatar($userID, $size=0)

But that didn't work very well… I put it where the "get_avatar()" tag is now, and First of all it was dreadfully slow Yes – I enabled avatar template tags in the code optimalization admin page). 
Also, when I turned on the option "override wp avatars with forum avatars", that also made the load times very slow.

Secondly, it created a lot of extra code, and it didn't place the avatar where I wanted it.. would it maybe be better if it coughed up something more similar to "get_avatar"?

The reason for why I wanted to use "sf_show_members_avatar()" is of course that it would allow locally uploaded avatars, not dependent on "gravatar.com".

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: SPQC, kailas, VikingBrent
51 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 485

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2616

Members: 7328

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10839

Posts: 79131

Moderators: Brandon C (158)

Administrators: Yellow Swordfish (22131), Mr Papa (23587)