• I am trying to modify/sanitize values returned from additional profile fields which I have added using the user_contactmethods filter. I am able to validate and throw errors using the user_profile_update_errors action, but I can’t find a way to filter/modify/sanitize values.

    Another way of putting it: how do I take a value like Twitter Name, and add a ‘@’ character if there isn’t one – I don’t need the regex, I am looking for the hook to enable me to run the function against the $_POST[‘twitter’] before the meta update. The order of things is quite confusing.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have you had a look at Data_Validation?

    Thread Starter Lucien Taylor

    (@lucien-taylor)

    Yes, I use validation all the time. I can get it working on other extra profile fields, but not on extra user contact fields. For example, if I want to clean out non-integers on a Google ID using absint($_POST[‘google’]) where do I put that? The change is firing very quickly, and there doesn’t seem to be a hook to validate/sanitize user contact info in time before the update.

    If you use the Settings_API, you will be able to use your own validation & sanitization callback as part of register_setting(). https://ottopress.com/2009/wordpress-settings-api-tutorial/ is a good tutorial on this.

    Question about using user_contactmethods filter.

    I have it working how I want but what if I wanted to separate my data from the Contact Info heading to a section called User Application and then display the information under that heading.

    How do i make that happen? Thank You!

    Moderator bcworkz

    (@bcworkz)

    @bradbarker
    You can suppress the output of that filter by returning an empty array, then use the Settings API to add your own section. Be sure to use the same field names.

    You cannot suppress the e-mail and Website fields so easily with PHP via a clean hack, nor the section title. You would need to enqueue a jQuery admin script that removes that particular content.

    FYI, though your question is related, it is still preferred you start your own topic for your own questions. In addition, more people are likely to see a new topic than a question tacked on to an older thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to modify additional profile contact values?’ is closed to new replies.