BuddyDev

Search

To/From Values custom field issue

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

    Hi there, I really like the ‘To/from Values’ custom field. Thanks for adding this to the list of field types, it works really well!

    I am using the Enhanced Member Cards to add more profile information to the members list.
    Unfortunately the To/From Values custom field only display the title, but not the numeric values, only a little dot.

    It seems like it is not accepted by other plugins using these fields, as a genuine custom field.

    The question is, where the issue lies?

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #16899

    Hi Carsten,
    Thank you for posting.

    It has most probably to do with the difference between bp_profile_data and xprofile_get_field_data s used.

    Please allow me to use this field today and regenerate the issue. I will post a solution later today.

    Thank you
    Brajesh

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

    I am looking forward to that, again thank you for your responsiveness.

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #16933

    Hi Carsten,
    I have looked at it now and I can see the issue. The problem lies that the xprofile_get_field_data ad the other method passes individual value to display filter while the display filter expects array.

    A simple solution for now will be use it like this

    
    echo join( '-', (array) xprofile_get_field_data( 'Field Name', bp_get_member_user_id() ) );
    
    

    Please change the field name with actual field name and it will work.

    Regards
    Brajesh

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

    Thanks a lot, for coming up with a solution so prompt, I will have a look at it, and see if it work out for me too.

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #16936

    Thank you. Please do let me know how it goes.

    Regards
    Brajesh

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

    It doesn’t work for me, but I am not sure, where to copy the code snippet – in the bp-xprofile-custom-field-types.php or bp-custom.php or some were else?

    by the way, can the field name contain æøå letters?

    regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #16947

    Hi Carsten,

    If you can tell me where you want to show it I can help. The above function needs user_id and the function I am using is for BuddyPress member loop.

    There are multiple ways to add code. I had assumed that you wer manually adding the above code to member loop.

    Please let me know where you want to make it appear
    – Member header
    – or member directory

    Also, We can use field id instead of the field name if that makes sense. You can see the field id from Dashboard->Users->profile Fields page.

    Regards
    Brajesh

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

    Hej Brajesh, I would like it displayed in the member directory. The field id is 2374.

    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #17021

    Hi Carsten,

    If you are using bp-legacy template pack,you can use the following code in bp-custom.php or in your child theme’s functions.php

    
    
    /**
     * Show the field in members list(directory).
     */
    function buddydev_custom_show_field_in_members_list() {
    	echo join( '-', (array) xprofile_get_field_data( 2374, bp_get_member_user_id() ) );
    }
    
    add_action( 'bp_directory_members_item', 'buddydev_custom_show_field_in_members_list' );
    
    

    If you are using the bp-nouveau, you will need to edit their members-loop.php and put the line

    
    echo join( '-', (array) xprofile_get_field_data( 2374, bp_get_member_user_id() ) );
    
    

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved