Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get Xprofile field of page author


  • jaudain
    Participant

    @jaudain

    Hey There, I need a bit of help, I’m basically trying to echo a field, but so far i’ve only been able to do this.

    <?php echo xprofile_get_field_data( 'TWITCH TV Username', $current_user->ID ); ?>

    Currently this will echo said field for the currently logged in user, but what i need is to get the field for the author of the page.

    Ive tried <?php echo xprofile_get_field_data( 'TWITCH TV Username', get_the_author_id() ); ?>
    But this just returns nothing at all.

    Any help would be great, thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Looks like the problem is that the WP function you’re using is deprecated. Try

    get_the_author_meta('ID')

    https://codex.wordpress.org/Function_Reference/get_the_author_meta


    jaudain
    Participant

    @jaudain

    Thanks for the reply, You we’re right it was deprecated, however still no joy.

    e.g. <?php echo xprofile_get_field_data( 'TWITCH TV Username', get_the_author_meta('ID') ); ?>

    Also tried <?php echo xprofile_get_field_data( 'TWITCH TV Username', the_author_meta('ID') ); ?> re: https://codex.wordpress.org/Template_Tags/the_author_meta

    Also with no joy.

    Any other thoughts


    jaudain
    Participant

    @jaudain

    Sorry to double post, but I’m still not sure how to do this, or am I doing something wrong?


    jaudain
    Participant

    @jaudain

    Update: I seem to have figured it out.

    The problem was i was using the_author_meta('ID') which has an echo built into it to display the info, so instead i used get_the_author_meta('ID') and now it seems to be working ok.

    Really strange because i was sure i tried it already lol.

    <?php echo xprofile_get_field_data( 'TWITCH TV Username', get_the_author_meta('ID') ); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get Xprofile field of page author’ is closed to new replies.
Skip to toolbar