Skip to:
Content
Pages
Categories
Search
Top
Bottom

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


  • 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)

  • shanebp
    Moderator

    @shanebp

    Try:

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

    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’ );


    shanebp
    Moderator

    @shanebp

    Use bp_get_member_profile_data( 'field=Hair' );


    jaybee08
    Participant

    @jaybee08

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Output "Not Provided" if bp_member_profile_data is empty or null’ is closed to new replies.
Skip to toolbar