• Resolved Mike Harvey

    (@mbuk89)


    I have set up a conditional field radio button, a simple ‘Yes’ or ‘No’ answer as part of registration form. If user selects ‘Yes’ then another form field appears which requires a 6 digit account number to be typed in. This all works fine.
    However if a user enters any data into that field then decides to change original answer to ‘No’, the field is then hidden (which is fine) but when they create an account the data that was entered in the hidden field is still sent to the admin email (New user email notification)

    Is there a way that if a user changes their mind after inputting data in a field which then becomes hidden, it clears the field instantly, so no data is sent in the ‘new user email’ to admin?

    I hope this isn’t too confusing! Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • missveronica

    (@missveronicatv)

    @mbuk89

    When I tried to reproduce your issue I found:

    1. If user looks at the hidden text field again after changing to No,
    the text field is cleared by JavaScript and nothing is being sent.

    2. If user answers Yes, enters the text then enter No again
    without looking at the hidden text again
    the text is sent as submitted data.

    You can try this code snippet,
    install into your active theme’s functions.php file
    or use the “Code Snippets” plugin.

    Update with your meta_keys these lines:

        $radio_meta_key = 'yes_no_cond';
        $code_meta_key  = 'yes_no_text';
    add_filter( 'um_add_user_frontend_submitted', 'add_user_frontend_check_custom_condition', 10, 1 );
    
    function add_user_frontend_check_custom_condition( $args ){
    
        $radio_meta_key = 'yes_no_cond';
        $code_meta_key  = 'yes_no_text';
    
        if( isset( $args[$radio_meta_key] ) && is_array( $args[$radio_meta_key] )) {
            if( isset( $args[$radio_meta_key][0] ) && $args[$radio_meta_key][0] == 'No' ) {
                if( !empty( $args[$code_meta_key] )) {
                    $args[$code_meta_key] = '';
                    $args['submitted'][$code_meta_key] = '';
                }
            }
        }
        return $args;
    }
    Thread Starter Mike Harvey

    (@mbuk89)

    @missveronicatv

    Perfect! I have applied this to my site and this has solved the issue I was having!

    Thanks for your help with this

    missveronica

    (@missveronicatv)

    @mbuk89

    I have posted an UM bug report about this Conditional Logic issue.

    https://github.com/ultimatemember/ultimatemember/issues/1097

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hidden field data being sent to admin email’ is closed to new replies.