Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display xprofile field in blog post?


  • Anton
    Participant

    @antonrsaopencirclecoza

    I have created a custom profile field ‘About me’ and I would like to display that underneath each blog post to give the reader some information regarding the blog post author.

    I know how to do this getting the default “Biographical Info” from the user admin’s panel but then it will mean that the author has to complete two “bio” sections. One on the custom field I have created and on the wp admin section.

    This is what I include on single.php for the blog post:

    <?php echo xprofile_get_field_data( ‘About me’, the_author_id()) ?>

    it only returns the id, numerically of the blog author

    What can do to include that custom xprofile field underneath each blog post?

Viewing 8 replies - 1 through 8 (of 8 total)

  • Bowe
    Participant

    @bowromir

    Good question.. I did not know it was possible to display BP related info into blogposts? That could lead to many cool things like a “About me” widget on a user blog which displays info coming from their BP profile..


    peterverkooijen
    Participant

    @peterverkooijen

    We were discussing displaying single xprofile fields here.

    Someone gave me this function:

    function custom_xprofile( $field ) {
    echo bp_custom_get_member_list_xprofile_data( $field );
    }
    function bp_custom_get_member_list_xprofile_data( $field ) {
    global $site_members_template;
    return xprofile_get_field_data( $field, $site_members_template->member->id );
    }

    So you can use this in the members index.php:

    <p><?php custom_xprofile('Company') ?></p>

    But it only works in members_template. I’d like to have a function for xprofile fields that works anywhere…

    Haven’t had time to try variations on this one. Suggestions very welcome!

    @Anton Koekemoer, I’m pretty sure the key would be in replacing $site_members_template in the function, but I wouldn’t know with what.

    EDIT2: Here’s the thread where I originally got the function, from John James Jacoby.


    Anton
    Participant

    @antonrsaopencirclecoza

    @Peterverkooijen.

    I looked at that thread and was searching around to check if that’s possible. I’m sure I saw a thread somewhere where someone similar tried to do this with a custom xprofile Twitter profile field. Can’t find it now :(


    Anton
    Participant

    @antonrsaopencirclecoza

    This is where I got the idea from but it doesn’t seem to work:

    https://buddypress.org/forums/topic/displaying-profile-fields-in-blog-posts


    Anton
    Participant

    @antonrsaopencirclecoza

    Is it even possible to display “custom” xprofile fields in blog posts?


    r-a-y
    Keymaster

    @r-a-y

    I’m answering the first post to this thread.

    You can’t use an echo’d parameter (eg. the_author_id()), that is why your function isn’t displaying the xprofile field.

    Parameters need to be returned, so use get_the_author_id() instead.

    Example:

    <?php echo xprofile_get_field_data( 'About me', get_the_author_id()) ?>


    Anton
    Participant

    @antonrsaopencirclecoza

    @r-a-y

    Excellent! Thanks for that.


    zanzaboonda
    Participant

    @zanzaboonda

    @r-a-y this helped me out so much… you have no idea. Thank you!

    One more question, though, if you are available to help.

    Is there a way to turn an xprofile field into a tag? I’m trying to track posts by country so we could then click on the country and see all the posts from that country. (I have a drop down of all countries as a required registration field.)

    Or is there a better way to go about it? I don’t mind learning/doing work, I just have no idea how to go about it. Any ideas?

    Thanks and best wishes,
    Kristen

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display xprofile field in blog post?’ is closed to new replies.
Skip to toolbar