Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Display certain profile fields on members profile page (9 posts)

Started 10 months ago by: naijaping

  • Profile picture of naijaping naijaping said 10 months ago:

    Hi, i will like to display some profile field at the members profile page, i know i can do that by adding the following code to members-header.php, but how can i put a link, so that if the field is not filled by the member it will just show let say “add your Country” and when click it will just go to the place where he can fill the field

    <div id="member_profile">
    <?php if ( $data = bp_get_profile_field_data( 'field=Country' ) ) : ?-->
    <div class="profile_fields">
             Country: <span><!--?php echo $data ?--></span></div>
    <?php endif ?--></div>

    regards

  • Profile picture of Tammie Lister karmatosed said 10 months ago:

    Could this work with a empty checking or null value on the $data? That would be my first suggestion.

  • Profile picture of naijaping naijaping said 10 months ago:

    I think it could be achieved by adding an empty checking which i have no clue. i think something loke “if empty return” could do.

  • Profile picture of Alan Alan said 10 months ago:
    <div id="member_profile"><!-- #member_profile -->
            <?php
            global $bp;
            $data = bp_get_profile_field_data('field=Country');
            $user_status = is_user_logged_in() ;
            $add_data_link = $bp->loggedin_user->domain .  '/profile/edit/group/1';
            ?>
    
        <div class="profile_fields"><!-- .profile_fields -->
    
            <?php if(!empty($data) && $user_status): ?>
    
            <?php echo $data;?>
    
            <?php elseif($user_status): ?>
    
            <?php echo '<a href="'. $add_data_link .'" title="Music Videos">'. 'Add Your Coutnry'.'</a>'; ?>
    
        </div><!-- .profile_fields -->
    
        <?php endif;?>
    
        </div><!-- #member_profile -->

    Make sure that you change the link in $add_data_link at the end … you can check out the slug and see in what group is the Country field located …

  • Profile picture of naijaping naijaping said 10 months ago:

    @Alan, i will try it and if i run into any problem , i will let you know.

    regards

  • Profile picture of naijaping naijaping said 10 months ago:

    @Alan, or can someone please help me look at this code to know if something is wrong, have tried it and everything seems ok if the member did not add the “country field” as it shows the link and take you to the edit page, but immediately you input the field “Country” e.g “UK” and save, it breaks both Admin bar and the Sidebar.

  • Profile picture of naijaping naijaping said 9 months, 2 weeks ago:

    @uloga,or can someone please help me look at this code to know if something is wrong, have tried it and everything seems ok if the member did not add the “country field” as it shows the link and take you to the edit page, but immediately you input the field “Country” e.g “UK” and save, it breaks both Admin bar and the Sidebar. please someone help.

  • Profile picture of alfredojp alfredojp said 9 months, 2 weeks ago:

    Try this:

    <?php
    		  bp_profile_field_data( 'field=Country' ); 
    
    		?>
  • Profile picture of naijaping naijaping said 9 months, 2 weeks ago:

    @alfredojp, thanks for your input, i know i can use that code to get some profile field but if you read my post you will know that what am trying to achieve is more than just profile field.

    thanks anyways