Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Problems using apostrophes and accented characters in profile field (7 posts)

Started 1 year, 7 months ago by: zoltok

  • Profile picture of zoltok zoltok said 1 year, 7 months ago:

    Hello there,

    I have added a field in the user setup that uses both accented characters and an apostrophe (Année d’inscription). I am having a lot of difficulty calling and testing this field in both the members directory and the individual profile.

    In the members directory, I have to remove both the accents and the apostrophe from the profile field for this to work. Neither using a backslash for the apostrophe nor the character code for the accented characters worked.
    bp_profile_field_data( 'field=Annee dinscription' )
    In the individual profile, I can get away with the accents, but not the apostrophe. I tried adding a backslash, to no avail.
    I can play around with the wording, but avoiding accents will be almost impossible here. Any advice?

  • Profile picture of r-a-y r-a-y said 1 year, 7 months ago:

    Instead of relying on the field name, try the field id instead:

    bp_profile_field_data( 'field=1' );
    
    // 1 = your field id

    You can find the field id by hovering over the “Edit” or “Delete” button of the field name on the Profile Field Setup screen.

  • Profile picture of zoltok zoltok said 1 year, 7 months ago:

    Hi r-a-y,

    Good suggestion. This worked perfectly for the single members page. However, I’m still having the same problem on the Member Directory page… This returns nothing:

    bp_get_member_profile_data( 'field=17' );
  • Profile picture of zoltok zoltok said 1 year, 7 months ago:

    Alrighty, I figured it out!!
    So, it looks like the function “bp_get_member_profile_data”, which is suggested for use on the members-loop page, doesn’t work with field IDs, nor accents, nor apostrophes. To get around this, I used the function that is used in member-header.php (bp_profile_field_data), which does accept field IDs, but specified the user. Here was the final code I used:

    bp_get_profile_field_data( 'field=17&user_id=' . bp_get_member_user_id() );

    Hope this helps somebody!

  • Profile picture of Chouf1 Chouf1 said 1 year, 6 months ago:

    i think it would be better that you code your php in english
    The output with accent is ok without hacking on
    See here where is a demo field with many acdcented and special characters, without touching the core code.

    http://bp-fr.net/members/admin/profile/public/

  • Profile picture of zoltok zoltok said 1 year, 6 months ago:

    Hi Chouf1,

    Perhaps you’ve misunderstood. Accented fields are not a problem to create or use if you’re using the basic template – my problems only arose when I tried to call those fields and use them conditionally in the members loop in a customized theme. So, for example , that would be equivalent to displaying the results from your “Champ supplémentaire n° 4 bis ” on this page: http://bp-fr.net/members/. I haven’t touched the core code, the modifications are in my theme files.

    If you have an alternative solution though, please feel free to share it.

  • Profile picture of Chouf1 Chouf1 said 1 year, 6 months ago:

    Maybe ;-)
    Have you read this :

    http://trac.buddypress.org/ticket/2171