What i am trying to accomplish is similar if not exactly what is done here:
[[LINK href="http://wordpress.org/support/topic/get_the_author_meta-conditional-display"]]here[[/LINK]]
When a user registers on my site, i have an extra custom field that they fill in. This extra custom field is done via the plugin via [[LINK href="http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/documentation/"]]Cimy user extra fields[[/LINK]]
The custom field is called which_phone_do_you_have
And in the drop down, there are two choices: iPhone 5, Galaxy S3
A user picks his choice,and registers as normal.
Now when a user is viewing his profile page, which is a custom profile.php i created where i want a picture of Galaxy S3 to show, since he chosen Galaxy S3 as his phone.
My steps:
[[LINK href="http://i.imgur.com/gROvI.png"]]creating the field[[/LINK]]
[[LINK href="http://i.imgur.com/Ui252.png"]]User selects a phone type at registration[[/LINK]]
[[LINK href="http://i.imgur.com/ATOvF.png"]]His choice appears in wordpress backend[[/LINK]]
[[LINK href="http://i.imgur.com/OCMc0.png"]]The custom made profile page where i want the image to appear[[/LINK]]
[[LINK href="http://i.imgur.com/epJ2L.png"]]The code in my custom profile page, which is not working[[/LINK]]
Some articles on similair, if not the same as what i am trying to accomplish
I noticed in the cimey documentation something about :
FUNCTIONS USEFUL FOR YOUR THEMES OR TEMPLATES:
[Function get_cimyFieldValue]
NOTE: password fields values will not be returned for security reasons
USAGE:
$value = get_cimyFieldValue($user_id, $field_name, [$field_value]);
but i'm not savvy enough to implement it.
Jatin Soni answers:
Try this code. This code I used for my custom author profile page. Hope this will works.
<?php
global $wp_query; $curauth = $wp_query->get_queried_object();
$device = $curauth->which_phone_do_you_have; //this is yoru meta key
if (!empty($device)){
echo $device;
}
?>
However if Custom Field you mean by post custom field than above code may not work. In that case you may need to use get_post_meta instead. Let me know either you are talking about Post's Custom Field or something else.
For Post Custom Field you should use something below
if (get_post_meta($post->ID, 'which_phone_do_you_have', true ))
echo //your code
//OR
if (get_post_meta($post->ID, 'which_phone_do_you_have', true ) != '')
echo //your code
Jatin Soni comments:
So now use the code I have provided in last PM.
Dbranes answers:
Hi,
if you mean fx: http://example.com/author/joe where you have the template file author.php,
you could try to add this code:
<?php $phone_type = get_the_author_meta( 'which_phone_do_you_have' ); ?>
<?php if($phone_type == "iPhone 5"){?>
<img src="http://example.com/iphone5.jpg" alt="iPhone 5"/>
<?php }elseif($phone_type == "Galaxy S3"){?>
<img src="http://example.com/galaxy_s3.jpg" alt="Galaxy S3"/>
<?php }?>
</code>
into author.php.