BuddyDev

Search

[Resolved] Show Xprofile Field Data code is not working with Xprofile Member Type Field

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #37349

    Hi there, for some reason this part of the code below does not work with Xprofile Member Type Field?

    $field_data_gender = xprofile_get_field_data( 'Gender:', bp_get_member_user_id() ); where ‘Gender:’ is the name of the field

    Any idea why?

    Regards
    Carsten

    /**
     * Show Xprofile Field Data After The username in The Members Directory. https://gist.github.com/KaineLabs/f431ef4177757e61f9a638607c9879e0
     */
    function yzc_add_xprofile_field_data_after_username( $name ) {
    	if ( bp_is_members_directory() ) {
    
    		$field_data      = xprofile_get_field_data( 'Age:', bp_get_member_user_id() );
    		$field_data_gender = xprofile_get_field_data( 'Gender:', bp_get_member_user_id() );
    
    		return $name . " <span class='bp-user-age'> <br/>" . $field_data_gender . ", " . $field_data . "</span>";
    
    	}
    
    	return $name;
    }
    
    add_filter( 'bp_member_name', 'yzc_add_xprofile_field_data_after_username', 10 );
  • Participant
    Level: Yogi
    Posts: 1105
    calu on #37351

    Hi there, I can see that it is actually working with the code.

    The problem was that members registered earlier, before I started using Member Types, have to be updated manually, not only in the Users list> Change member type to…
    drop down,

    imgur.com/i91GkYe

    but also in the extended profile settings as well, which apparently is not updated with the Users list settings.

    imgur.com/dAuu6oE

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #37353

    Hi Carsten,
    Thank you.

    I am not sure what are you using for the member type in xprofiel field. Can you please tell me how are you adding the field. That may explain it.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #37358

    Hi Brajesh, thanks for your prompt reply, I have created two Member Types ID’s, and a Single Member Type field for the two ID’s.

    It’s working now, I think the problem was the old profile types earlier were created with drop down profile fields, which was messing things up when converting to Member Types instead.

    Therefore the member type for each old member had to be defined in the extended field settings.

    I hope this makes sense.

    Did you have time to look at my customisation request?

    Regards
    Carsten

    • This reply was modified 3 years ago by calu.

You must be logged in to reply to this topic.

This topic is: resolved