• Matt

    (@mugwumpman)


    WordPress keeps switching parts of users’ firstname fields into their lastname fields, and we don’t know how to stop this.

    I have a client who’s members (users) are hostels, and so may have 1-5 words in their name. (e.g. ‘Derwentwater Independent Hostel’ or ‘Avon Tyrrell Activity Centre’)
    We try to split it meaningfully and put the most important part in the firstname field and the less important name in the lastname field. That means we can display the data meaningfully in their publications e.g.

    DERWENTWATER
    Independent Hostel
    – or –
    AVON TYRRELL
    Activity Centre

    However, we find that occasionally (seemingly at random) a hostel will loose a part of it’s firstname which will be pushed into the lastname field, so our publication titles get altered to…

    AVON
    Tyrrell Activity Centre

    This is a pain for us, and our members complain when it happens to them. So we try to keep an eye out and manually change it back when it happens, but there must be a way to stop it happening?

Viewing 13 replies - 1 through 13 (of 13 total)
  • What is being selected for each user for “Display name publicly as”?

    Thread Starter Matt

    (@mugwumpman)

    [Firstname] [Lastname], so ‘Avon Tyrrell Activity Centre’, which is what usually displays on the site frontend.

    The main place the firstname & lastname fields are used separately is when exporting to the book that they publish (The Independent Hostel Guide) and in user material such as forums and communications.

    Thread Starter Matt

    (@mugwumpman)

    Is there a part of WordPress’ code that periodically sanitises user details, such as maybe forcing the firstname to be one word and pushing the rest into the lastname field? If there is, could someone could point me towards that?

    It would make sense if such a script was running, because at the same time as the name reshuffle, the name also gets altered to Title Case.

    e.g. “AVON TYRRELL” “ACTIVITY CENTRE” becomes “Avon” “Tyrrell Activity Centre”

    Do you have an example of a page where the issue is occurring?

    It could be an issue with your markup or styling. If separation of the first and last name is important, I’d suggest getting them separately with get_userdata() instead of relying on the display settings.

    Is there a part of WordPress’ code that periodically sanitises user details, such as maybe forcing the firstname to be one word and pushing the rest into the lastname field?

    Not that I’m am aware of. If anything, this is usually controlled by your theme. Can you replicate the problem using the Twenty Sixteen theme? Tried deactivating all plugins?

    Thread Starter Matt

    (@mugwumpman)

    @jacob I’m viewing this data directly in phpmyadmin, so I wouldn’t say it’s an issue with display.
    But in answer to your question, we use <?php bp_displayed_user_fullname(); ?> on the user’s profile pages seeing as we want it all displayed, but for the book export we need to display the seactions differently, so take them separately from the respective table fields with a MYSQL query:

    SELECT meta_value FROM wp_usermeta WHERE user_id = $id AND meta_key LIKE 'first_name'

    SELECT meta_value FROM wp_usermeta WHERE user_id = $id AND meta_key LIKE 'last_name'

    The important thing is that when we look up the first_name and last_name fields in phpmyadmin, the values in them change inexplicably, and that’s what we’re trying to stop, or at least find out what’s causing the change.

    @esmi We’ve tried that with a dev site, but it’s a hard problem to replicate as it happens intermittently and without us doing anything. (Hence we thought it might be some wp_cron script.) I guess I should really try setting up a remote dev and leaving it running for a few weeks.

    That is very unusual. Are you using BuddyPress? You might have more luck on the BuddyPress boards: https://buddypress.org/support/

    bp_displayed_user_fullname() is not a WordPress function – it’s a Buddypress one. Given that you are using Buddypress, have you asked about this on the BuddyPress forums?

    Thread Starter Matt

    (@mugwumpman)

    Ahah good point. But the display itself doesn’t seem to be the issue, as the data is changed in the database table, before it reaches any display code.

    Can your users edit their name? Are you sure they’re not making the change?

    Thread Starter Matt

    (@mugwumpman)

    As for finding a trigger for the change, I thought the following actions could be close enough to trigger the bug, but none do:

    • Update userdata (Core)
    • Import userdata from Book (Custom)
    • Export userdata to Book (Custom)
    • Export userdata to Mailchimp (Mailchimp for WP)

    Are there any other actions that might trigger such a change in userdata, particularly in core?
    (I’ll check in the buddypress forums in case it’s buddypress related)

    PS – many thanks for the blazing-fast responses btw!

    The other possibility is that Buddypress or another plugin is making the changes.

    Thread Starter Matt

    (@mugwumpman)

    Can your users edit their name? Are you sure they’re not making the change?

    It’s highly unlikely, as they are the ones that complain about it if their names get changed. Also, when it happens it’s a consistent change like it’s being parsed by some code, rather than the variety of changes you would expect if multiple unrelated users are changing their names.

    So we don’t know what triggers it, but when it does take place, two things happen:

    1. The first_name & last_name values change from uppercase to title case.
    2. Any first_name values more than one word long (in other words ones that contain a space) get shortened to the first word and the remaining words get prepended to the last_name value.

    The other possibility is that Buddypress or another plugin is making the changes.

    If that’s the case I’ll see if I can find something in the buddypress forums, and meanwhile set the remote dev server going to check if it occurs without theme & plugins.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘User's names are automatically changed’ is closed to new replies.