advancedforms / advanced-forms

WordPress plugin to create forms using Advanced Custom Fields
75 stars 14 forks source link

Save value of hidden field with post info #48

Closed rcobiella closed 5 years ago

rcobiella commented 5 years ago

Hello,

I just got the Pro version of the plugin and I have to say I'm loving it. However, I'm trying to figure out how to save post data stored in a hidden field when submitting.

Here's what I have:

$form_key = 'form_5c059ce94b013';
function hidden_field($form,$args) {
    $form_post_title = get_the_title() ? get_the_title() : 'Unknown';
    echo '<input type="hidden" name="order_product" value="'.$form_post_title.'">';
}
add_action( 'af/form/hidden_fields/key='.$form_key, 'hidden_field', 10, 2 );

When inspecting I actually see the hidden field being added to the form, so I guess that part is right. The problem is that I cannot find the field on the stored entry in the back-end. Am I missing something?

Thanks in advance.

fabianlindfors commented 5 years ago

Hi! I'm sorry about the late reply to this.

Do you still need help with your hidden fields?

rcobiella commented 5 years ago

Hey!

No problem. I ended up doing something else, so didn't need this in the end. But thanks for the reply!

klsdfr commented 1 year ago

Hi! I'm sorry about the late reply to this.

Do you still need help with your hidden fields?

Hey @fabianlindfors I'm running into the exact same problem. The hidden field added via code is added to the form, but unfortunately I can't figure out how to save the value to the submitted entry and include it in the mail.

How can I achieve this? Thanks in advance! :)

fabianlindfors commented 1 year ago

Hey @klsdfr! I'm no longer involved with AF so I'll have to defer to @mishterk!

klsdfr commented 1 year ago

Okay at least I got the values of the hidden fields I needed from the $_POST array. Unfortunately they are not inside the AF()->submission Object