Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problems using apostrophes and accented characters in profile field

  • Avatar of zoltok
    zoltok
    Participant

    @zoltok

    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    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.

    Avatar of zoltok
    zoltok
    Participant

    @zoltok

    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′ );
    `

    Avatar of zoltok
    zoltok
    Participant

    @zoltok

    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!

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    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/

    Avatar of zoltok
    zoltok
    Participant

    @zoltok

    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.

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Maybe ;-)
    Have you read this :

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

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.