Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter martyy

    (@martyy)

    maybe I could be more precise:
    I have a bilingual buddypress community. I use multisite (each language on a seperate site) and the sites share the same user base. I would like to display the label of certain fields differently on the different languages. So I thought I could write a plugin for a specific site and change the labels this way. Is that possible? and if so, could you provide me with the code, I mean just the filter?

    Thread Starter martyy

    (@martyy)

    I tried the following with no result:

    add_filter( 'bxcft_field_label', 'change_label', 10,1);
    function change_label($id){
      if($id == 1){
      $label_to_return = "Color";
      return $label_to_return;
      }
    }
    Plugin Author donmik

    (@atallos)

    Hi,

    Try this:

    add_filter('bxcft_field_label', 'my_field_label', 10, 2);
    function my_field_label($label, $field_id) {
        if ($field_id == 1){
            $label_to_return = "Color";
            return $label_to_return;
        }
        return $label;
    }

    But this will only change the label in the form, not when viewing profile. When you view profile you will need to change the template.

    Thread Starter martyy

    (@martyy)

    Hi,
    thank you. I applied your code but don’t get any result on any form. Not in the registration form nor on the edit profile. But I suppose as you mentioned it is only possible for the registration.
    What does the id refer to?
    I used 1 because I wanted to change the name for the field with the id of 1 in my databse table wp_bp_xprofile_fields. Is that correct?

    Plugin Author donmik

    (@atallos)

    This is possible for registration form and edit profile form.

    You can only use this filter for the fields which are using a field type provided by my plugin. If it’s a field with a type from buddypress defaults, you cannot use this filter.

    To know the id of a field, you can try to edit a profile field and in the url you can see something like this:
    page=bp-profile-setup&group_id=1&field_id=31&mode=edit_field

    31 is the id of this field.

    But I believe 1 is the id of the default and required field of buddypress “Name” so you cannot change this with the filter provided by my plugin. You can use buddypress filter “bp_get_the_profile_field_name” to do this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change the Label’ is closed to new replies.