Community Support Forums — WordPress® ( Users Helping Users ) — 2011-04-13T16:51:31-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=3091 2011-04-13T16:51:31-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9695#p9695 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]> http://jobs.wordpress.net too. :)

Statistics: Posted by Cristián Lávaque — April 13th, 2011, 4:51 pm


]]>
2011-04-13T16:28:45-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9691#p9691 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]>
Code:
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
get_userdatabylogin(get_the_author_login());
(
get_the_author_login());
else :
$curauth = get_userdata(intval($author));
endif;
?>


I tried everything, but I can't get it to work. I posted this in the custom coding section of your forum, but no luck so far. Any other suggestions?

Thanks for your help!

Statistics: Posted by rvlatum — April 13th, 2011, 4:28 pm


]]>
2011-04-12T21:08:08-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9628#p9628 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]> Thanks for the follow-up.

Once you have the User's ID, you can use this s2Member API function.
Code:
<?php get_user_field("city", $user_id); ?>
Where "city" is the Custom Field ID that you configured with s2Member.

Integrating this into the author.php file is another matter. If you need assistance with custom coding, you might post a project request here: viewforum.php?f=37

Statistics: Posted by Jason Caldwell — April 12th, 2011, 9:08 pm


]]>
2011-04-12T20:57:52-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9625#p9625 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]> Example. I have three custom fields in the s2 plugin (bio, company profile and company)
How can I show the content of these fields for every user?

two random profiles (author.php)
see: http://www.entrepreneur21.net/author/sr ... rated-com/
http://www.entrepreneur21.net/author/rvlatum/

Statistics: Posted by rvlatum — April 12th, 2011, 8:57 pm


]]>
2011-04-12T20:43:42-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9624#p9624 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]>
Code:
<?php
$current_user 
= wp_get_current_user();
$user_id = $current_user->ID;
?>


Another technique, if you know their Username:
Code:
<?php
$user 
= new WP_User("johndoe22");
$user_id = $user->ID;
?>


You can also use the get_users() function.
http://codex.wordpress.org/Function_Reference/get_users
Code:
<?php
foreach(get_users("role=s2member_level1") as $user)
    $user_id = $user->ID;
?>

Statistics: Posted by Jason Caldwell — April 12th, 2011, 8:43 pm


]]>
2011-04-12T10:57:03-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9575#p9575 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]> wordpress does this like this:

Code:
<?php global $current_user; get_currentuserinfo(); echo $curauth->display_name; ?>


I can't work with individual ID's, I need something like the example above.

Thanks for your help by the way!

Statistics: Posted by rvlatum — April 12th, 2011, 10:57 am


]]>
2011-04-12T10:50:35-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9574#p9574 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]>
If you look at the function parameters, you'll notice the optional value for user ID, which defaults to the current user. So, if you want it to be for some other user, just pass his ID when calling the function. Like this:

Code:
get_user_field('city'23); // 23 is the user's ID. 

Statistics: Posted by Cristián Lávaque — April 12th, 2011, 10:50 am


]]>
2011-04-12T09:53:09-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9572#p9572 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]> I am using the author page for this. After a user is logged in, I need that page to show some fields from the plugin. Now, it's showing the info from the user that is logged in, but I need it to show the info from the user's profile that I am visiting.

Statistics: Posted by rvlatum — April 12th, 2011, 9:53 am


]]>
2011-04-12T03:07:16-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9544#p9544 <![CDATA[Re: <?php echo get_user_field("city"); ?>]]>

From s2member/includes/functions/api-functions.inc.php
Code:
/*
Retrieves a Custom Field value.
$field_id - required argument.
$user_id - defaults to current user.
*/
if (!function_exists ("get_user_field"))
    {
        function get_user_field ($field_id = FALSE, $user_id = FALSE)
            {
                return c_ws_plugin__s2member_utils_users::get_user_field ($field_id, $user_id);
            }
    } 


I hope that helps. :)

Statistics: Posted by Cristián Lávaque — April 12th, 2011, 3:07 am


]]>
2011-04-11T20:04:10-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3091&p=9499#p9499 <![CDATA[<?php echo get_user_field("city"); ?>]]>
Code:
<?php echo get_user_field("city"); ?>


Works great for the user that's logged in, but how can I show a field from on a profile from any user?
I tried

Code:
<?php echo get_current_user_field("city,"); ?>


But that didn't work. What am I doing wrong?

Thanks a lot!

Statistics: Posted by rvlatum — April 11th, 2011, 8:04 pm


]]>