Page 1 of 1
S2member user custom field
Posted:
August 1st, 2011, 12:27 pm
by jeansuhas
Hi there,
I have purchased the S2member pro. Sounds awesome.
I have a question:
- user custom field generated by S2member are meta?
- does it means that i can display them somewhere on my theme using this type of code:
<?php echo esc_attr( get_the_author_meta( 'contact_number' ) ); ?>
I have tried. it is not working.
How can i do it?
regards
Re: S2member user custom field
Posted:
August 1st, 2011, 10:14 pm
by Cristián Lávaque
This may help you with that
viewtopic.php?f=4&t=6546&p=16582#p16582Read the whole thread to understand it better.
Re: S2member user custom field
Posted:
August 4th, 2011, 12:55 pm
by jeansuhas
ok thank you. BUT
the code works when a connected user want to see the information of another user (custom field). Unfortunately a visitor (unregistered) won't be able to see the information.
I used this peace of code in my theme for the field "adress2":
<span>
<?php echo get_user_field("adress2"); ?>
</span>
To you know any hacks to allow custom fiel diplaying for unregistered users?
Regards
Re: S2member user custom field
Posted:
August 4th, 2011, 11:35 pm
by Cristián Lávaque
I don't understand... You want to see the custom field of an account that doesn't exist because the person hasn't registered?
Re: S2member user custom field
Posted:
August 5th, 2011, 5:34 am
by jeansuhas
If i am not registered or logged in, i want to be able to see the custom field of a registered user.
Re: S2member user custom field
Posted:
August 5th, 2011, 10:26 pm
by Cristián Lávaque
Re: S2member user custom field
Posted:
August 7th, 2011, 12:29 pm
by jeansuhas
Please I couldn't find the answer. I already used the stated function it is not showing for unregistered users.
why?
Re: S2member user custom field
Posted:
August 8th, 2011, 1:25 pm
by Cristián Lávaque
Could you please show me the code you're using and how you're using it?
Re: S2member user custom field
Posted:
August 8th, 2011, 2:02 pm
by jeansuhas
- Code: Select all
<?php } ?>
<div class="contact">
<span class="button" ><?php echo $woo_options['woo_label_contact_agent_button']; ?></span>
<div class="agent-popup">
<?php the_commenter_avatar(array('avatar_size'=>'56')) ?>
<div class="details">
<?php $first_name = esc_attr( get_the_author_meta( 'first_name' ) ); ?>
<?php $last_name = esc_attr( get_the_author_meta( 'last_name' ) ); ?>
<?php if ( ($first_name != '') && ($last_name != '') ) { $display_name = $first_name.' '.$last_name; } else { $display_name = esc_attr( get_the_author_meta( 'display_name' ) ); } ?>
<span class="name"><?php echo $display_name; ?></span>
<span>
<?php echo esc_attr( get_the_author_meta( 'contact_number' ) ); ?>
</span>
<span>
<?php echo get_user_field("agency"); ?>
</span>
<span>
<?php $author_email = esc_attr( get_the_author_meta( 'user_email' ) ); ?>
<input type="text" style="display:none;" value="<?php echo $author_email; ?>" id="email" name="email" />
<?php if ($woo_options['woo_contact_form_link'] == 'true') { ?>
<a href="<?php bloginfo('url'); ?>/<?php echo $woo_options['woo_contact_form_page']; ?>/?propertyid=<?php echo $post->ID; ?>&agentid=<?php echo get_the_author_meta( 'ID' ); ?>" title="<?php echo $author_email; ?>"><?php echo $woo_options['woo_label_agent_email_link']; ?></a><?php } else { ?>
<a href="mailto:<?php echo $author_email; ?>" title="<?php echo $author_email; ?>"><?php echo $woo_options['woo_label_agent_email_link']; ?></a><?php } ?>
</span>
Re: S2member user custom field
Posted:
August 8th, 2011, 3:53 pm
by Cristián Lávaque
I see what you're doing. The problem is that you're not telling get_user_field the ID of the user. It should be like this:
- Code: Select all
echo get_user_field('agency', $author_id);
I should see the code that comes before what you quoted to have a better idea of how to get the author's ID, but maybe this would work:
- Code: Select all
$author_id = get_the_author_meta('ID');
So
- Code: Select all
<?php echo get_user_field('agency', get_the_author_meta('ID')); ?>
I hope that helps.