Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

meta_value conditional statement WordPress


What i am trying to accomplish is similar if not exactly what is done here:

[[LINK href=""]]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=""]]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=""]]creating the field[[/LINK]]

[[LINK href=""]]User selects a phone type at registration[[/LINK]]

[[LINK href=""]]His choice appears in wordpress backend[[/LINK]]

[[LINK href=""]]The custom made profile page where i want the image to appear[[/LINK]]

[[LINK href=""]]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 :

[Function get_cimyFieldValue]
NOTE: password fields values will not be returned for security reasons


$value = get_cimyFieldValue($user_id, $field_name, [$field_value]);

but i'm not savvy enough to implement it.

Answers (2)


Jatin Soni answers:

Try this code. This code I used for my custom author profile page. Hope this will works.


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


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:


if you mean fx: 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="" alt="iPhone 5"/>
<?php }elseif($phone_type == "Galaxy S3"){?>
<img src="" alt="Galaxy S3"/>
<?php }?>


into author.php.