Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Output "Not Provided" if bp_member_profile_data is empty or null

  • Avatar of jaybee08
    jaybee08
    Participant

    @jaybee08

    Hello buddypress users,

    I am trying to achieve to display “Not Provided” if user has not fill out a certain xprofile field. Below is the code I’ve used but seems doesn’t work:

    <?php $hair = bp_member_profile_data( ‘field=Hair’ ); if($hair == null ) { echo $not_provided; } else { echo $hair; } ?>

    example:

    Hair: Not provided
    eyes: blue
    earings: Not Provided

    Any help from you guys would be greatly appreciated.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Try:

    $hair = bp_member_profile_data( 'field=Hair' ); 
    if( ! $hair  ) 
       echo 'Hair: Not Provided';  
    else 
       echo 'Hair: ' . $hair; 
    Avatar of jaybee08
    jaybee08
    Participant

    @jaybee08

    @shabebp Thanks for your response. I tried that way but it doesn’t work. It echoes the field value wherever you place this variable $hair = bp_member_profile_data( ‘field=Hair’ );

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Use bp_get_member_profile_data( 'field=Hair' );

    Avatar of jaybee08
    jaybee08
    Participant

    @jaybee08

    @shanebp, it works like a charm. thank you for your help.

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

You must be logged in to reply to this topic.