I have a WP plugin, where all admin setting field values were suddenly changed to the letter 'a'. All settings are stored in one 'big' option in the table. Seemed like the serialization gone wrong.

I run a var_dump on the get_option value and it returned a truncated string, not an array as usual. I'll update the question once I can reproduce the truncated string again.

I only use the 'Save changes' button and let the WP Options API write to the option, getting the values from user changeable or hidden HTML fields.

Is there any special characters or similar that can prevent an option from being written properly which could result in the serialized array being truncated?

The cause has something to to with Instagram or an Instagram user name.

  • 1
    Incompatible character encodings (ISO-8859-1 versus UTF-8) can result in truncated strings. But this happens usually in the first invalid byte, not as early as on the first letter. But check the encoding nevertheless.
    – fuxia
    Jun 23, 2013 at 9:57
  • Did you check what is written to database? Is there a correct value for this options fields or is it saved incorrectly? Jun 23, 2013 at 11:54
  • 2
    Then write an answer with all the details please. And mark your question as answered.
    – fuxia
    Jun 23, 2013 at 17:17

1 Answer 1


It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it's a username.

trim(preg_replace("/[^\w\s]+/", "", $user->full_name))

I assumed there are no special characters in Instagram usernames. Never assume. I don't really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence of the special character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.