This topic contains 2 reply and 2 voices, and was last updated by rfarmer 6 years, 7 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
April 20, 2013 at 7:17 pm 2619
rfarmer I have some custom fields for my Registration Form and I want to display those on my theme's 'author.php' page. I cannot get them to display the data using the syntax from the documentation. Is there a different treatment for registration form custom fields? I can get it working fine for regular forms on posts. <?php get_header(); ?> <?php $show_sidebar = (get_option('thestyle_sidebar') == 'on') ? true : false; ?> <h3>Location</h3> <?php echo get_post_meta( $post->ID, 'location', true ); ?> <h3>Website</h3> <a href="<?php echo get_post_meta( $post->ID, 'user-website', true ); ?>"><?php echo get_post_meta( $post->ID, 'user-website', true ); ?></a> <div id="content" class="clearfix<?php if ($show_sidebar && get_option('thestyle_blog_style') == 'false') echo(' sidebar-fixedwidth'); ?>"> <div id="boxes" class="<?php if (!$show_sidebar) echo('fullwidth'); if (get_option('thestyle_blog_style') == 'on') echo(' blogstyle-entries'); ?>"> <?php get_template_part('includes/entry'); ?> <?php get_footer(); ?>   http://cookiehound.iwantedryanfarmer.com/author/testnametwo/
April 20, 2013 at 7:56 pm 2620
Tareq Hasan Tareq Hasan

`get_post_meta()` is for posts, `get_user_meta()` is for registration or users custom field.

One more thing, `$post->ID` refers to the post ID, where for authors profile, you need to get the user ID. To get the current users ID, add this code after `get_header()`:
[php]
<?php
$curauth = (get_query_var(‘author_name’)) ? get_user_by(‘slug’, get_query_var(‘author_name’)) : get_userdata(get_query_var(‘author’));
?>
[/php]

Now you can show the user location like this
[php]<?php echo get_user_meta( $curauth->ID, ‘location’, true ); ?>[/php]

April 20, 2013 at 8:14 pm 2621
rfarmer rfarmer

Perfect. Thank You!

Viewing 2 Posts - 1 through 2 (of 2 total)