828 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+5 more
Gareth_Gillman says

Having a slight problem echo’ing some data in WP and need a slight nudge in the right direction

I am listing recent pages (using wp_list_comments) on another page outside of the loop, and need to grab the user data (for their profile).

I have the following:

echo the_author_meta( 'location' );

Which displays the Location field from the profile, but I need to add the user_id to the query which would be:

echo the_author_meta( 'location', 25 );

However I am generating the user ID using user_id() so need to do the following:

echo the_author_meta( 'location', user_id() );

Which gives the usual syntax errors

What is the best way of doing this?

646 posts Fuel Your Web
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a competition
  • Had an item featured on Envato Market
  • Has been part of the Envato Community for over 7 years
+5 more
Pirenko says

What are the usual syntax errors? Paste them here…

1552 posts How's the surf doing?
  • Nominated Community Superstar of the month
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 3 years
  • Had an item featured on Envato Market
+7 more
tommusrhodus says

There’s every chance I’m wrong here, but wouldn’t it best to assign user_id(); to a variable first and then call that variable in place within the_author_meta(); function?

828 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+5 more
Gareth_Gillman says

Thanks Tommus

Nearly there but still not showing the field

foreach($comments as $comment) { ?>
 <?php $user = $comment->user_id ?>
 Location: <?php echo the_author_meta( 'location', $user ); ?>

No errors anymore but not showing the field! Any ideas?

1552 posts How's the surf doing?
  • Nominated Community Superstar of the month
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 3 years
  • Had an item featured on Envato Market
+7 more
tommusrhodus says

Again this is just guess work, but this line:

 <?php $user = $comment->user_id ?> 

Would this work?

 <?php $user = $comment->user_id(); ?> 

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by