Page 1 of 1

Member directory

PostPosted: June 18th, 2011, 12:15 pm
by arbie
I am trying to work out how I can output the members to create a publicly visible member directory.
Essentially I need a directory listing the users by first and last name (with a name search preferably), then individual pages for each user (accessible by clicking the users name in the directory). That page would then be the user profile page and would include their
Name
Membership level
Time of joining
Next renewal date
Member picture (which I add)
Member description/summary
All of the usual plugins miss the S2Member info and only output the normal wordpress info. I want it the other way around!
Think I can work it out?
<sigh>
Nope!
Anyone feeling generous with their knowledge?
(My S2Member is pro if that helps....)

Re: Member directory

PostPosted: June 18th, 2011, 10:49 pm
by Cristián Lávaque
This tutorial may help you viewtopic.php?f=4&t=6536

This plugin may be useful too https://wordpress.org/extend/plugins/members-list/

I hope that helps. :)

Re: Member directory

PostPosted: June 19th, 2011, 3:06 am
by arbie
Hmmm...I am not the owner of a WP-User file sadly so I am guessing that is out of date or for a version of WP that is much older than current.... Hacking up the core files for WP seems counter intuitive as well. S2Member must store that data somewhere - surely hacking up a plugin to call that data makes more sense than messing with core files (that will be overwritten when you need to update).
Thanks - but I think I will keep looking on that one...

[FOLLOW UP]
The plugin mentioned above (now installed) picks up the S2Member fields so there is no additional work to do to any wordpress files.
Essentially it is now just a case of styling the page.....

Re: Member directory

PostPosted: June 19th, 2011, 11:20 am
by Cristián Lávaque
Thanks for the update. I'm glad that helped you solve it. :)

Re: Member directory

PostPosted: June 19th, 2011, 12:08 pm
by arbie
Okay - almost there (I'll post full details once I have it sorted.)
The one thing I cannot do is output the level of the member being displayed.
Essentially, the plugin is listing the users - that is fine. Each user then becomes a link, which outputs to author.php. I can output everything (even have an S2 conditional to allow logged in members to see the member's email - but not a non-logged in visitor).
The bit that I cannot get to output is the displayed member's level. Tried c_ws_plugin_s2_member_user_access::user access label - but this displays the user viewing (either nothing if not logged in or the user logged in) I have searched through the classes etc, and nowhere can I find something that will allow me to output the user who is being displayed on the author.php page's level.
Anyone have any clues?

UPDATE
Okay - so I have given up on auto outputting the user level for now (I am manually adding the image for now so it is only an extra little bit of typing).
The code that I added to author.php is:
Code: Select all
                        <h2>Accredited Member Profile</h2>
<?php
$thisauthor 
= get_userdata(intval($author));
?>
<div style="float: right;"><h5 style="text-align:right;margin-right:10px;"><?php echo $thisauthor->display_name; ?>'s qr Code</h5>
<? if(function_exists('get_avatar')) { echo get_avatar($thisauthor->user_email, 150, "" ); } ?> </div>
<h3><?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?> (<?php echo $thisauthor->display_name; ?>)</h3>
<h5>Accredited member since:&nbsp;<?php $registered = ($thisauthor->user_registered . "\n");
  echo date("j/n/Y", strtotime($registered)); ?></h5>
<h5><?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?>'s website: <a href="<? echo $thisauthor->user_url; ?>"><? echo $thisauthor->user_url; ?></a><br /></h5>
<h5>Email&nbsp;<?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?>
:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN){ ?> <a href="mailto:<? echo $thisauthor->user_email; ?>">Email Address</a>&nbsp;<?php } else { ?> (Only available to accredited members)<?php } ?></h5>

<p>&nbsp;</p>
<hr />
<p>&nbsp;</p>
<h3>What&nbsp;<?php echo $thisauthor->display_name; ?>&nbsp;says about themselves:</h3>
<p><?php echo $thisauthor->description; ?> </p>

<?php if (have_posts()) : ?>


<? endif; ?>


Which works fine (output example is: http://aospuk.co.uk/author/aospuk) - probably need to tidy the layout up some - but busily adding the content to the site - so css is acceptable for now....(must get rid of all those
Code: Select all
&nbsp;
and empty paragraphs at some stage!)

Re: Member directory

PostPosted: June 19th, 2011, 11:14 pm
by Cristián Lávaque
For the label try

Code: Select all
echo c_ws_plugin__s2member_user_access::user_access_label($user_id); 

Re: Member directory

PostPosted: June 20th, 2011, 2:24 am
by arbie
yeah already tried that (see earlier post) added $thisauthor as well (in place of user_id) - user_id outputs nothing and thisauthor throws a php error.

Re: Member directory

PostPosted: June 20th, 2011, 1:24 pm
by Cristián Lávaque
When you mentioned it before it wasn't obvious that you had tried specifying the user. I wrote $user_id to give it an descriptive name, but if you don't have that variable defined then it won't work. If $thisauthor is not the user ID, it won't work either. In you case the user's ID seems to be $author, although I may be wrong, make sure it is. What you have to enter there is the user's ID (that's why I had named the variable $user_id for the example).

I hope that helps.

Re: Member directory

PostPosted: June 20th, 2011, 1:31 pm
by arbie
The code that I am using was posted above - and
$thisauthor
is the variable on
author.php
(which is a WP function).

I've given up guessing what I need to do - might go back to it another time....

Re: Member directory

PostPosted: June 20th, 2011, 10:10 pm
by Cristián Lávaque
Could you try this?

Code: Select all
echo c_ws_plugin__s2member_user_access::user_access_label(intval($author));  

Re: Member directory

PostPosted: June 21st, 2011, 2:52 am
by arbie
Thanks for that - but no output at all. Tried $thisauthor at the end as well. Double checked that it was not giving any output by placing the php inside h5 tags and then adding a character before php - character outputs as h5 title - no other output (web developer for FF shows no other element than the character in the h5 tags)

Re: Member directory

PostPosted: June 21st, 2011, 10:15 am
by Cristián Lávaque
Is that user at a level that has a label? Try this instead

Code: Select all
echo c_ws_plugin__s2member_user_access::user_access_role(intval($author)); 


By the way, here's the documentation for those, in case you haven't read it yet. viewtopic.php?f=40&t=9477&src_doc_v=110605

Re: Member directory

PostPosted: June 21st, 2011, 10:38 am
by arbie
Code: Select all
<h5><?php echo c_ws_plugin__s2member_user_access::user_access_role(intval($author)); ?></h5>

Added and results in:

Image

(the code above should appear between website and email address)

And I DID read the literature - and watch a bunch of videos - that's why I posted here.... thanks for making me feel like I'm asking noob questions though.

Re: Member directory

PostPosted: June 21st, 2011, 11:20 am
by Cristián Lávaque
I'll ask Jason why it may not be working.

Re: Member directory

PostPosted: June 21st, 2011, 11:30 am
by Cristián Lávaque
In the meantime, could you try if this works?

Code: Select all
echo get_user_field('s2member_access_label'$thisauthor->ID); 

Re: Member directory

PostPosted: June 21st, 2011, 1:04 pm
by arbie
That got it! - well done Cristian - not just a pretty face!

Saves me having to type that one out each time - much obliged!

Re: Member directory

PostPosted: June 21st, 2011, 4:35 pm
by arbie
For anyone that looks in - here is the full code that I am using:

Code: Select all
<?php
$thisauthor 
get_userdata(intval($author));
?>
<div style="float: right;"><h5 style="text-align:right;margin-right:10px;"><?php echo $thisauthor->display_name?>'s qr Code</h5>
<? if(function_exists('get_avatar')) { echo get_avatar($thisauthor->user_email150"" ); } ?> </div>
<h3><?php echo $thisauthor->first_name " " $thisauthor->last_name?> (<?php echo $thisauthor->display_name?>)</h3>
<h5>Accredited member since:&nbsp;<?php $registered = ($thisauthor->user_registered "\n");
  echo 
date("j/n/Y"strtotime($registered)); ?></h5>
<h5><?php echo $thisauthor->first_name " " $thisauthor->last_name?>'s website: <a href="<? echo $thisauthor->user_url?>"><? echo $thisauthor->user_url?></a><br /></h5>
<h5>Accredited as a <?php echo get_user_field('s2member_access_label'$thisauthor->ID); ?> member</h5>
<h5>This member's accreditation number is: <?php echo $thisauthor->ID?> </h5>
<h5>Email&nbsp;<?php echo $thisauthor->first_name " " $thisauthor->last_name?>
:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN){ ?> <a href="mailto:<? echo $thisauthor->user_email?>">Email Address</a>&nbsp;<?php } else { ?> (Only available to accredited members)<?php ?></h5>

<p>&nbsp;</p>
<hr />
<p>&nbsp;</p>
<h3>What&nbsp;<?php echo $thisauthor->display_name?>&nbsp;says about themselves:</h3>
<p><?php echo $thisauthor->description?> </p>


Need to sort the layout now and it is all done...

Once again Cristian - much obliged

Re: Member directory

PostPosted: June 22nd, 2011, 12:27 am
by Cristián Lávaque
You're welcome! I'm glad I finally managed to help you make it work. :)