Community Support Forums — WordPress® ( Users Helping Users ) — 2011-10-13T08:55:20-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=6501 2011-10-13T08:55:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=46787#p46787 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>
<?php echo get_user_field('Contact_Number', $author); ?>
<?php echo get_user_field('Contact_Number', get_the_author_meta( 'ID' )); ?>

"Contact_Number" is a Custom Field I made to hold a telephone number.
I made that in 'General Options', 'Registration/Profile Fields and Options' and then 'Add new Field'

Admin, please correct if wrong but this worked OK for me.

Statistics: Posted by Sim2K — October 13th, 2011, 8:55 am


]]>
2011-10-12T21:24:45-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=46761#p46761 <![CDATA[Re: Access custom registratation fields through PHP and disp]]> Statistics: Posted by Sim2K — October 12th, 2011, 9:24 pm


]]>
2011-05-23T02:17:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15613#p15613 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>

Statistics: Posted by Cristián Lávaque — May 23rd, 2011, 2:17 am


]]>
2011-05-23T00:12:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15607#p15607 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>
I much appreciate your support and good manner in supporting users of s2Member.

The way I managed to get get_userdata() to work is bit different from what you mentioned though. I list it here if anyone interested.

This is how I've access db field using user_data
Code:
$user_data->first_name


And s2Member custom field
Code:
$user_data->wp_s2member_custom_fields['mobile']


Anyway thumbs up for you Cristan.


Cheers
Nad

Statistics: Posted by talkdownunder — May 23rd, 2011, 12:12 am


]]>
2011-05-20T02:09:10-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15482#p15482 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>

I'm glad that solved your problem!

Regarding your question, you see, the first name is not really an s2Member custom field, so it won't be in that array. That array will only have s2Member's custom fields you created that the user's profile has, you can print_r the array to see the contents.

Code:
<pre><?php print_r($fields); ?></pre>


get_user_field is an s2Member function, doesn't come with WordPress, and will give you first_name, last_name and user_email although they aren't custom fields, to make it more convenient. Sorry about the confusion because of that.

Actually I think it's better that you use the array rather than query each custom field individually, with the array you do a single query for all the fields and then use the ones you need.

Actually, since you don't just need the custom fields but also other data about the user, it's even better if you use the WordPress function get_userdata, which also returns an array with first_name, last_name and much more, including s2Member's custom fields.

Code:
$user_data = get_userdata($user_id);
print_r($user_data); 


The line of code you mention above would be like this

Code:
echo $data['ID'] . ' - ' . $user_data['first_name'] . ' ' . $user_data['last_name'] . '<br/>';
  


An s2Member custom field would be here

Code:
echo 'My custom field is ' . $user_data['wp_s2member_custom_fields']['my_custom_field'];
  


Now, you're using $data['ID'], how did you create the $data array? If you used get_userdata, then you already have it all in $data.

Statistics: Posted by Cristián Lávaque — May 20th, 2011, 2:09 am


]]>
2011-05-20T00:32:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15478#p15478 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>
Who the hell are you Cristian ???

Its that easy ???
Yeh it works.

I wanna hug you man.

This line works as piece of cake.
Code:
echo $data['ID']." - ".get_user_field('first_name', $data['ID'])." ".get_user_field('last_name', $data['ID'])."<br/>";


How I get this one to work? please. How can I extract "first_name" out of it?
Code:
$fields = get_user_option('s2member_custom_fields', $data['ID']);

Statistics: Posted by talkdownunder — May 20th, 2011, 12:32 am


]]>
2011-05-20T00:18:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15476#p15476 <![CDATA[Re: Access custom registratation fields through PHP and disp]]>
Code:
$field = get_user_field('my_custom_field', $user_id); 


Or get all the fields in an array

Code:
$fields = get_user_option('s2member_custom_fields', $user_id); 

Statistics: Posted by Cristián Lávaque — May 20th, 2011, 12:18 am


]]>
2011-05-19T23:19:23-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6501&p=15469#p15469 <![CDATA[Access custom registratation fields through PHP and display]]>
I want to have separate Member Directory on the website. While having 12 custom registration fields, only few of the member information will be displayed in that Member Directory (which will be accessible to all the members).

Since custom registration fields are not actual mysql table fields, what will be the best way of accessing them to filter and display required member information on the Member Directory?

Thanks heaps.
Nad

Statistics: Posted by talkdownunder — May 19th, 2011, 11:19 pm


]]>