Hidden field data being sent to admin email

[ad_1]

@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;
}

@missveronicatv

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

Thanks for your help with this

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer