PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Displaying Custom Member Fields

s2Member Plugin. A Membership plugin for WordPress®.

Displaying Custom Member Fields

Postby AaronHolbrook » August 3rd, 2011, 3:17 pm

I did a couple searches here and on google and couldn't find anything.

I'd think this would be fairly straightforward - since adding custom registration fields is easy, but I can't figure out what function to use to call to get those custom registration fields to display out (like in a member directory).

Any ideas where to look?
User avatar
AaronHolbrook
Registered User
Registered User
 
Posts: 4
Joined: July 29, 2011

Re: Displaying Custom Member Fields

Postby Cristián Lávaque » August 3rd, 2011, 11:21 pm

Hi Aaron.

You can do something like

Code: Select all
$user = get_user_option('s2member_custom_fields', $user_id); 


Here's a example use of that viewtopic.php?f=4&t=6546&p=16582#p16582

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying Custom Member Fields

Postby AaronHolbrook » August 4th, 2011, 8:23 pm

Thanks Cristian.

Just in case anyone else was needing a good way to query the database for the custom registration fields this is what I did. The only issue is that parsing the database for unserialized data could potentially be insecure and come back to bite you in the ass if they ever change the serialization function for arrays.

Code: Select all
add_filter('posts_where', 'a7author_search_where' );

function a7author_search_where($a7auth_param) {
   global $wpdb;

   $querystr = "
      SELECT       $wpdb->usermeta.user_id
      FROM       $wpdb->usermeta
      WHERE       $wpdb->usermeta.meta_value LIKE '%post_code%" . $a7auth_param . "%'
      
   ";

   $author2 = $wpdb->get_results($querystr);
   
   return $author2;
}
User avatar
AaronHolbrook
Registered User
Registered User
 
Posts: 4
Joined: July 29, 2011

Re: Displaying Custom Member Fields

Postby Cristián Lávaque » August 5th, 2011, 1:06 am

Thanks Aaron. :)

Would that example get you members that have a certain post code?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying Custom Member Fields

Postby AaronHolbrook » August 5th, 2011, 7:33 am

yea exactly - my custom registration field setup through s2member was post_code, and I needed to return results based on a search query, so that's a way I figured out how to search the database looking for that information.

I'll post something more inclusive when I'm all finished.
User avatar
AaronHolbrook
Registered User
Registered User
 
Posts: 4
Joined: July 29, 2011

Re: Displaying Custom Member Fields

Postby Cristián Lávaque » August 5th, 2011, 10:30 pm

Great. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 1 guest

cron