[Plugin: Cimy User Extra Fields] fields not showing up on author profile page
-
Hi,
I am using Author Avatar to display a list of all freelancing users on my website so that they can be contacted by clients. I used Cimy User Extra Fields to add necessary fields to the profile. The fields show up on the profile but not on the actual author profile page on the website. What am I doing wrong and what do I need to add to the template to make them show up on the author page? It did not seem to be covered in Marco’s documentation or FAQ.
The link to the list of users is here: https://editorswa.com/?page_id=208 and the link to one of the author profile pages is here: https://editorswa.com/?author=1
Please help! Especially if it involves PHP because I am way out of my comfort zone here.
Thanks, Marisa.
-
Take a look at the file wp-content/plugins/cimy_user_extra_fields/README_OFFICIAL.txt.
It contains a little documentation on the functions used to retrieve the cimy values from the database. Here is an excerpt from that document:
get an extra field value from a specific user
PARAMETERS: pass user_id as first parameter and field_name as second
RETURNED VALUE: the function will return a string containing the valueGENERIC:
$value = get_cimyFieldValue(<user_id>, <field_name>);
EXAMPLE:
$value = get_cimyFieldValue(1, ‘MY_FIELD’);
echo cimy_uef_sanitize_content($value);CASE 2:
get all extra fields values from a specific userPARAMETERS: pass user_id as first parameter and a boolean set to false as second
RETURNED VALUE: the function will return an associative array containing all extra fields values from that user, this array is ordered by field orderGENERIC:
$values = get_cimyFieldValue(<user_id>, false);
EXAMPLE:
$values = get_cimyFieldValue(1, false);foreach ($values as $value) {
echo $value[‘NAME’];
echo $value[‘LABEL’];
echo cimy_uef_sanitize_content($value[‘VALUE’]);
}I suspect that what you want to use on the author page is the second case – get all values for a specific user. So, suppose you have the author id in a variable $author_id, you would get all values for that author with this code:
$values = get_cimyFieldValue($author_id, false); foreach ($values as $value) { $values_by_name[$value['NAME']] = cimy_uef_sanitize_content($value['VALUE']); }
Then, to show the Telephone, for example, you would code:
echo $values_by_name['TELEPHONE'];
I realize that this is pretty heavy PHP if you are not used to it. If you can email me a copy of the template used to produce the page, and a list of the names of the cimy fields, I can probably give more specific directions. My email is m_a_mcdonald =at= bellsouth =dot= net.
Ok I am really daft at php so I probably need someone to write it out for me or something. I tried putting in what you suggested but it still isn’t showing up on the public page.
<?php /* get all options: */ include (TEMPLATEPATH . '/functions/bfa_get_options.php'); get_header(); ?> <?php $thisauthor = get_userdata(intval($author)); ?> <div style="float: right;"> <? if(function_exists('get_avatar')) { echo get_avatar($thisauthor->user_email, 96, "" ); } ?> </div> <h3>You're currently viewing <?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?>'s freelance profile </h3> <p><h4> General information </h4></p> <p>user_url; ?>"><? echo $thisauthor->user_url; ?> user_email; ?>"><? echo $thisauthor->user_email; ?> <p>Telephone:<?php echo $thisauthor->TELEPHONE; ?></p> <p>Mobile:<?php echo $thisauthor->mobile; ?></p> <p>Business address:<?php echo $thisauthor->address; ?></p> <p><h4>Editing experience and information</h4></p> <p><?php echo $thisauthor->user_description; ?> </p> <p>Qualifications:<?php echo $thisauthor->qualifications; ?></p> <p>Services:<?php echo $thisauthor->services; ?></p> <p><h4>Social networking & chat</h4></p> <p>AIM ID:<?php echo $thisauthor->user_aim; ?></p> <p>Yahoo ID:<?php echo $thisauthor->user_yahoo; ?></p> <p>Twitter ID:<?php echo $thisauthor->user_twitter; ?></p> <p>MSN ID:<?php echo $thisauthor->user_msn; ?></p> <p>ICQ ID:<?php echo $thisauthor->user_icq; ?></p> <p>Skype ID:<?php echo $thisauthor->user_skype; ?></p>
After your Skype ID line, add this one example–of course you will need to know your Cimy field names so as to replace BIRTH-DATE with a correct field:
<p>Birth Date:<?php echo cimy_uef_sanitize_content(get_cimyFieldValue(1, 'BIRTH-DATE')); ?></p>
I am working on the code, but I need to know a little more about how this module is used. Is it INCLUDED from another module? Or is what you have shown an incomplete sample? Specifically, how is $author set?
@michaelh, I would recommend getting all CIMY extra fields with one call to minimize database queries.
[EDIT: I see the author=1 parameter in the URL now]
@michaelh, I would recommend getting all CIMY extra fields with one call to minimize database queries.
You and me both…but that statement, “if it involves PHP because I am way out of my comfort zone here.” made me do it! ??
@kiadri, check your email.
This is what I have now:
<?php /* //Template Name: author */ /* get all options: */ include (TEMPLATEPATH . '/functions/bfa_get_options.php'); get_header(); ?> <?php // $author = 2; //TESTING ONLY ?> <?php $thisauthor = get_userdata(intval($author)); if ($thisauthor) : $values = get_cimyFieldValue($author, false); foreach ($values as $value) { $values_by_name[$value['NAME']] = cimy_uef_sanitize_content($value['VALUE']); } ?> <div style="float: right;"> <?php if(function_exists('get_avatar')) { echo get_avatar($thisauthor->user_email, 96, "" ); } ?> </div> <h3><?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?></h3> <p>Website: <?php if ($thisauthor->user_url) { ?> user_url . '">' . $thisauthor->user_url . ''; ?> <?php } ?></p> <p>Email: <?php if ($thisauthor->user_email) { ?> user_email . '">' . $thisauthor->user_email . ''; ?> <?php } ?></p> <p>Weblog: <?php echo $values_by_name['WEBLOG']; ?></p> <p>Telephone: <?php echo $values_by_name['PHONE']; ?></p> <p>Mobile: <?php echo $values_by_name['MOBILE']; ?></p> <p>Business address: <?php echo $values_by_name['ADDRESS']; ?></p> <p><?php echo $thisauthor->user_description; ?> </p> <p>Qualifications: <?php echo $values_by_name['QUALIFICATIONS']; ?></p> <p>Services: <?php echo $values_by_name['SERVICES']; ?></p> <?php else: echo "<h2>Sorry, Author ID $author has not filled out their freelance profile yet.</h2>"; endif; ?> <?php get_footer(); ?>
Services is not showing up, ditto weblog, phone, mobile and biographical info aka user_description. Also changed the title of the page and that change isn’t showing up either. vtxyzzy: you’ve got mail.
And thank you for all the help so far, though I am a little bit confused about MichaelH’s
<p>Birth Date:<?php echo cimy_uef_sanitize_content(get_cimyFieldValue(1, 'BIRTH-DATE')); ?></p>
Are you saying I should put all the values seperated by commas in the ‘BIRTH-DATE’ section?Cheers, Marisa.
I am a little confused – when I look at your site now, I see all of the fields except Weblog. Is it working now, or is this some temporary display?
I realize that I probably did not spell the CIMY field names exactly the way they are in your database, but you should be able to fix that easily.
Also, please do not post long sections of code here – stick to email attachments.
Thanks
Mackiadri – you don’t need to wrap code in a blockquote, just need the beginning and ending backticks.
Hi vtxyzzy
I came across this conversation going between yourself and another forum member re: adding extra user fields from the Cimy Extra users Plugin into an Author.php file and I was hoping that you might be able to help me as well.
Lets say that I’ve got a few extra user fields:
CITY
GENDER
OCCUPATIONHow can I display them into my Author.php file. I’ve tried to follow the final code posted above but it’s not working for me (error).
I can email you my author.php file if you’d like (I tried the address you posted above but it got returned?) or simply post the code here if it makes it easier?
Anyhow, thank you in advance for any advice or help you can provide.
Cheers!
daleBefore we start exchanging emails, please try this. Use this code to retrieve the CIMY fields (assuming $author contains the author ID):
$values_by_name = array( // Assign defaults to all CIMY fields 'CITY' => '', 'GENDER' => '', 'OCCUPATION' => '' ); $values = get_cimyFieldValue($author, false); if ($values) { foreach ($values as $value) { $values_by_name[$value['NAME']] = cimy_uef_sanitize_content($value['VALUE']); } }
Then, to display a value, use code like this:
<p>City: <?php echo $values_by_name['CITY']; ?></p>
hi, i’m having a similar question to kiadri. i want to add the extra fields to my author.php page, and i don’t know really how to solve the author’s id problem.
to get the information i want to display on the author’s page i’m using:
echo $curauth->title1
i tried to understand all the explanations here, but they are pretty difficult when not a pro in php. :/
how could i do the same to add the new extra fields?you know that thing that happens when you ask something and right after you finished asking you find the answer… well.. it just happened, so no need for rescue here anymore… ??
i’ll add the link to your site to the credit of my site once is on line to say thanksQuite old, but anyway…
I′m not a PHP coder but I know how to show CImy extra fields in
author.php
.I created 2 extra fields: FACEBOOK and TWITTER. In
author.php
, add this code somewhere before<?php if(isset($_GET['author_name']))...
:<?php $user_ID =$curauth->ID ; $fb = get_cimyFieldValue( $user_ID , FACEBOOK); $tt = get_cimyFieldValue( $user_ID , TWITTER); ?>
Ok. now to show up these extra fields, just add follow:
<a href="<?php echo $tt; ?>" target="_blank" >Twitter</a> <a href="<?php echo $fb; ?>" target="_blank" >Facebook</a>
It′s works for me.
Now I have to guess how to show some fields at pages. Exemple: a page called “Our Authors” with avatars and name, linking to each author page.
- The topic ‘[Plugin: Cimy User Extra Fields] fields not showing up on author profile page’ is closed to new replies.