I just started using Cimy User Extra Fields on a site I’m working on, and it has some really fantastic features if you want to add information to your registration form, and your author bio or profile pages.
The one thing I have struggled with is getting the contents of a field to appear outside the Loop. I am using get_cimyFieldValue, which is disabled by default (so the first step is to enable it!). The readme explains how to get a field value to display in the Loop, but not outside of it.
The following instructions explain what to do, provided you are working with an Author Template file (author.php) per the instructions in the WordPress codex.
Your author.php file should begin looking something like this:
<?php get_header(); ?> <div id="content" class="narrowcolumn"> <!-- This sets the $curauth variable --> <?php if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif; ?>
You have called the header, and you’ve set the $curauth variable. This is EXTREMELY important. Without the $curauth variable, the rest of these instructions will produce nothing.
Now, let’s say you have used Cimy User Extra Fields to create a field for the user’s favorite color, named (appropriately) “FAV_COLOR”. You want the author’s profile to display the author’s favorite color, which is “red”.
Once you have declared the $currauth variable, you can use it to retrieve the author’s ID, which is what the get_cimyFieldValue function needs to call (and display) the author’s favorite color outside the loop.
<?php $value = get_cimyFieldValue($curauth->ID, 'FAV_COLOR'); ?> <?php echo $value; ?>
Note that $curath->ID replaces get_the_author_ID, because get_the_author_ID can only be used inside the Loop.
On the other hand, $curauth->ID can only be used in this example because the $curauth variable has been declared at the beginning of the file, and is now available for use in the rest of the template.
Once again, let me reiterate that you MUST have a working author.php file (with the $curauth variable declared at the outset) in order for this to function correctly.
Many thanks to Marco Cimmino developing Cimy User Extra Fields, and for his prompt and helpful support!!
4 Responses to “Cimy User Extra Fields: How to display field values outside the Loop”
Leave a Reply
- Chocolate Recipies (1)
- Code Snippets (4)
- How Tos (5)
- Internet (1)
- Plugins (2)
- Security (2)
- Tools (1)
- Tutorials (2)
- Webmaster (1)
- WordPress (7)



Marci, thank you very much!
I have also really struggled with getting the contents outside the loop an now it works immediately! An the for me most important thing is that ist works on a multiuser-blog!
Thanks!
Rita
Thanks for this post. This is just what I was looking for.
Glad to be of help!
Thank you. Thanks you. Thank you.
I’m not much of a PHP guru, so the Cimy Extra User Fields documentation was like Greek to me. Plus I was wanting to pull the fields from the author.php page as well.
It’s working perfectly now at Artnet.in.
Thanks again.