Skip to:

How to display static text as a profile field?

  • nhalation


    Well, not exactly static. But close enough. Here’s the deal: I’d like to add two profile fields when viewing a member’s profile: join date, and membership level (from another third party plugin).

    These should not be “real” profile fields, as I don’t want them to be editable by the user. I just want them to appear on profile pages as if they were profile fields.

    I don’t really need help with the functions to get the correct data, I have that, I just don’t have anywhere to hook it into. I can’t exactly use something like bp_before_profile_loop_content, as it’s not in the correct location, and if I hook it to bp_profile_field_item then it shows up in all groups, whereas I only want this info to display in the base group.

    Is there a better way of doing this?

Viewing 1 replies (of 1 total)

  • nhalation


    Well, with a bit more Googling I’ve gotten this solved for the most part. I know these pages get indexed so here’s what I did for anyone’s future reference. For this example’s sake I’ll just cover the “Member Since” field.

    – Created a copy of profile-loop.php in the appropriate child theme directory for update-safe modification.

    – In the child copy of profile-loop.php, right beneath <?php do_action( 'bp_after_profile_field_content' ); ?>, which is inside (and at the bottom) of the ‘if ( bp_profile_group_has_fields())’ if check, I put the following code to output this field for the base group only (assuming the base group has an ID of 1):

    <?php if ( bp_get_the_profile_group_id() == 1 ) : ?>
      <table class="profile-fields">
       <tr<?php bp_field_css_class(); ?>>
        <td class="label">Member Since</td>
        <td class="data"><?php bp_custom_profile_fields(); ?></td>
     <?php endif; ?>

    And then finally, in my child theme’s functions.php file (this could probably also go in bp-custom.php) I found and pasted this code to define and format the join date:

    function bp_custom_profile_fields() {
        global $bp;
        $currentuser = get_userdata( $bp->displayed_user->id );
        $joined = date("F jS, Y", strtotime($currentuser ->user_registered));
        echo '' . $joined . '';
Viewing 1 replies (of 1 total)
  • The topic ‘How to display static text as a profile field?’ is closed to new replies.
Skip to toolbar