Forums

[Plugin: Cimy User Extra Fields] fields not showing up on author profile page (18 posts)

  1. kiadri
    Member
    Posted 2 years ago #

    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: http://editorswa.com/?page_id=208 and the link to one of the author profile pages is here: http://editorswa.com/?author=1

    Please help! Especially if it involves PHP because I am way out of my comfort zone here.

    Thanks, Marisa.

  2. vtxyzzy
    Member
    Posted 2 years ago #

    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 value

    GENERIC:
    $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 user

    PARAMETERS: 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 order

    GENERIC:
    $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.

  3. kiadri
    Member
    Posted 2 years ago #

    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.

  4. kiadri
    Member
    Posted 2 years ago #

    <?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>
  5. MichaelH
    Volunteer
    Posted 2 years ago #

    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>
  6. vtxyzzy
    Member
    Posted 2 years ago #

    @kiadri,

    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]

  7. MichaelH
    Volunteer
    Posted 2 years ago #

    @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! ;)

  8. vtxyzzy
    Member
    Posted 2 years ago #

    @kiadri, check your email.

  9. kiadri
    Member
    Posted 2 years ago #

    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.

  10. vtxyzzy
    Member
    Posted 2 years ago #

    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
    Mac

  11. MichaelH
    Volunteer
    Posted 2 years ago #

    kiadri - you don't need to wrap code in a blockquote, just need the beginning and ending backticks.

  12. daledubilowski
    Member
    Posted 2 years ago #

    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
    OCCUPATION

    How 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!
    dale

  13. vtxyzzy
    Member
    Posted 2 years ago #

    Before 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>
  14. layabozi
    Member
    Posted 2 years ago #

    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?

  15. layabozi
    Member
    Posted 2 years ago #

    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 thanks

  16. Diana
    Member
    Posted 1 year ago #

    Quite 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.

  17. ryanleesharp
    Member
    Posted 1 year ago #

    I'm now having a similar issue, but I feel like I'm including the code you're suggesting...

    <?php
    
    //initializing variables
    global $wp_query;
    $query_vars = $wp_query->query_vars;
    
    //loading resources
    $curauth = get_userdatabylogin($query_vars['author_name']);
    $values = get_cimyFieldValue($curauth->ID, 'POSITION');
    $content = cimy_uef_sanitize_content($values);
    ?>
    <?php get_header(); ?>
    <div id="leftColumn">
    	<img src="<?php bloginfo('template_url'); ?>/images/content_top_shadow.png" width="607" height="10" class="content_tb_shadow" />
    	<div id="contentBackground">
    		<div id="contentAuthor">
    			<div id="contentTitleAuthor">
    				<h1><?php echo $curauth->first_name.' '.$curauth->last_name; ?></h1>
    				<div id="jobTitle">
    					<?php echo $content; ?>
    				</div>
    				<div id="email">| <?php echo $curauth->user_email; ?></div>
    				<br />
    			</div>
    				<div id="postContents">
    					<?php echo get_avatar( $curauth->ID, 350 ); ?>
    					<div id="postList">
    						<ul>
    						<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    							<li><?php the_time('m/j/Y') ?> - <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?> "><?php the_title(); ?></a></li>
    						<?php endwhile; else: ?>
    							<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    						<?php endif; ?>
    						</ul>
    					</div>
    					<img class="authorBar" src="<?php bloginfo('template_url'); ?>/images/footer_bar.png" />
    					<p><?php echo $curauth->user_description; ?></p>
    					<img class="authorBar" src="<?php bloginfo('template_url'); ?>/images/footer_bar.png" />
    				</div>
    			</div>
    		</div>
    		<img src="<?php bloginfo('template_url'); ?>/images/content_bottom_shadow.png" class="content_tb_shadow" />
    	</div>
    	<!-- END COMMENTS | START SIDEBAR -->
    
    	<?php include (TEMPLATEPATH . '/sidebar-blog.php'); ?>
    </div>
    
    <!-- END SIDEBAR | START FOOTER -->
    <?php get_footer(); ?>

    It's not showing up as you can see on this page...

    http://blog.zuberance.com/blog/author/cara-fuggetta/

    Any ideas? Thanks.

  18. hosteo
    Member
    Posted 1 year ago #

    I have a problem to display the fields and I think maybe you can help me.

    Each author fills in their respective fields (as the name TEST), but the end result in "author.php" always the same that "user 1", how the result should be different because each author has put a corresponding value on the field TEST in your profile page.

    Here attached the code:

    <?php
    $values = get_cimyFieldValue($author_id, false);
    foreach ($values as $value) {
       $values_by_name[$value['TEST']] = cimy_uef_sanitize_content($value['VALUE']);
    }
    echo cimy_uef_sanitize_content($value);
    ?>

    Excuse for my english...
    Best regards,

    David

Topic Closed

This topic has been closed to new replies.

About this Topic