V
V
vad1mmm2021-12-14 11:14:24
PHP
vad1mmm, 2021-12-14 11:14:24

How to set value for hidden field in Ninja Forms?

I have a WordPress site. I also use the woocommerce plugin. There is a form in the product card, when filling it out, the data is sent to the mail. The form has hidden fields, how can I add a value for these hidden fields that is stored in my variable? For example, my field key is: hidden_price And there is such a code, but I don't understand how to do it.

function nf_hidden_field_values( $value, $field_type, $field_settings ) {
    global $post;

    if ( $field_settings['key'] == 'hidden_price' ) {
        $value = get_field('100', $post->ID);  //число 100 - это например тот параметр, который я хочу передать
    }

    return $value;
}
add_filter( 'ninja_forms_render_default_value', 'nf_hidden_field_values', 10, 3 );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question