Skip Navigation

[Résolu] How to display Types User Fields on Author Page

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to display Types User Fields on Author Page using PHP?

Solution:
Echo the following in your php code:

types_render_usermeta( 'types_phone', array( "user_id" => $curauth->ID ) )

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 9 réponses, has 2 voix.

Last updated by OliverJ8211 Il y a 4 années et 1 mois.

Assigned support staff: Noman.

Auteur
Publications
#554993
Types Phone Field.png

Tell us what you are trying to do?
Display Types User Fields on Author.php page.

Is there any documentation that you are following?
https://codex.wordpress.org/Author_Templates
https://toolset.com/documentation/customizing-sites-using-php/functions/

So I have an author.php page set up.

I'm using PHP echo to display name, email etc..
i.e.

  • First Name: <?php echo $curauth->first_name; ?>
  • Last Name: <?php echo $curauth->last_name; ?>
  • Email: <?php echo $curauth->user_email; ?>
  • Which works.

    But my Types User Fields will not display. i.e.

  • Phone: <?php echo $curauth->wpcf-types_phone; ?>
  • You can see by the attached image "Types Phone Field.png" that the slug for the field is "types_phone" and I've added the wpcf- prefix as instructed here: https://toolset.com/documentation/customizing-sites-using-php/functions/ but they are not displaying.

    #555052

    Noman
    Supporter

    Languages: Anglais (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Hi Oliver,

    Thank you for contacting Toolset support. Please use the following code:

    <?php echo types_render_usermeta( 'types_phone', array() ); ?>
    

    For more info, please go to this link and Click on MORE and see How to use this field with php:
    https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

    Thank you

    #555072

    Thank you. How do I define the separator for fields with multiple values?

    #555105

    Noman
    Supporter

    Languages: Anglais (English )

    Timezone: Asia/Karachi (GMT+05:00)

    You would do it something like this:

     types_render_field( "my-checkboxes", array( "separator" => ", " ) ) 
    #555370
    <?php echo types_render_usermeta( 'types_phone', array() ); ?>

    does not work as you can see here: hidden link

    #555507

    I tried using the format in /wp-content/plugins/types/examples/author.php

    which is:

    <?php echo types_render_usermeta( "types_phone" ); ?>

    and it gives me this error:

    Warning: Missing argument 2 for types_render_usermeta(), called in /home/aftguild/public_html/wp-content/themes/teachsd/author.php on line 22 and defined in /home/aftguild/public_html/wp-content/plugins/types/library/toolset/types/embedded/frontend.php on line 383

    #555543

    Noman
    Supporter

    Languages: Anglais (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Hello,

    To further debug this issue I need to take a look at your setup and to request temporary website WP-admin and FTP info for your site to debug further and to help in resolving this. Your next answer will be private which means only you and I have access to it.

    === Please backup your database and website ===

    ✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

    Thank you

    #555562

    /public_html should not be at end of ftp url

    it should just be

    <em><u>hidden link</u></em>
    #555618

    Noman
    Supporter

    Languages: Anglais (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Hello,

    I have updated the code and it is working as expected now, please check here:
    hidden link

    Here is the updated code I have added:

    <?php echo types_render_usermeta( 'types_phone', array( "user_id" => $curauth->ID ) ); ?>
    

    Thank you

    #555766

    Thank You!