Skip to:

Validate custom xprofile field on edit profile page

  • Avatar of pankipan4e


    OK so I’m struggling with this one for hours now and can’t get it to work, but it feels like there is a strait forward simple and elegant solution. All I want to do is to validate the value of a custom xprofile email field when a member is editing its info. Trying to mimic how xprofile_screen_edit_profile() works with returning error before saving, I tried to add_action/add_filter/do_action/apply_filter to xprofile_updated_profile, xprofile_screen_edit_profile, bp_actions, bp_screens, xprofile_data_value_before_save and more, but I failed every time probably because I don’t know how to properly use them. All I want to do is simple as:

    function my_validate_email () {
        if (!is_email($field_id->value))
    bp_core_add_message( __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' ), 'error' );
    //and redirect back to editing, same like for the required fields
    add_action( 'bp_hook_here', 'my_validate_email' );

    Please help with the correct way of doing this, possibly without using additional plugin
    Thanks so much

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

You must be logged in to reply to this topic.