Adding additional fields to Confirmation area revisited

My question wasn’t answered well that I asked yesterday so I am going to give more detail in hopes of an answer. The reference to post is often used I have found. A lot of people have questions about adding to the confirmation area. I have used the code from this post but I still need clarification when using it for a field rather than a checkbox. The issue I am having is not the adding of the field but rather the getting the submitted answer to show up on my admin side. The problem is the following code

$add = ‘var app_newsletter=0;$(“#appointments_newsletter”:wink:.change(function(){if ($(“#appointments_newsletter”“:checked”:wink:){app_newsletter=1;}else{app_newsletter=0;}});’;

$script = str_replace( ‘”post_confirmation”,’, ‘”post_confirmation”, app_newsletter:app_newsletter,’, $script );

. This code is specifically for a checkbox. While researching the submit for a field I cannot seem to find the correct code to replace this for submission.

If you could help me with this one line I would really appreciate it.

  • aecnu
    • WP Unicorn

    Greetings weezie,

    Thank you for the details and custom code is beyond the scope of the support we provide here but we do try to help if we can.

    With that said I will see if I can get the lead developer in here with his invaluable insight into this plugin and custom coding for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Vladislav
    • Dead Eye Dev


    The code for the text input field is actually a bit simpler, as you don’t have to keep checking the checkbox state – you can just pull in the value. For an example, something like this could work:

    // Adding a newsletter subscription checkbox to confirmation area
    function add_newsletter_checkbox( $ret ) {
    $add = '<label><span>Get Newsletter</span><input type="text" id="appointments_newsletter" /> </label>';
    return $ret . $add;
    add_filter( 'app_additional_fields', 'add_newsletter_checkbox');

    // Modify script to submit the additional field
    function modify_script( $script ) {
    $add = 'var app_newsletter=0;$("#appointments_newsletter").change(function () {app_newsletter=$("#appointments_newsletter").val();});';
    $script = str_replace( '"post_confirmation",', '"post_confirmation", app_newsletter:app_newsletter,', $script );
    return $add. $script;
    add_filter( 'app_footer_scripts', 'modify_script');

    // Do something with submitted additional field, e.g. save it in user meta
    function save_newsletter_selection( $app_id ) {
    global $current_user;
    if ( isset( $_POST['app_newsletter'] ) )
    update_user_meta( $current_user->ID, 'app_newsletter', $_POST['app_newsletter'] );
    add_action( 'app_new_appointment', 'save_newsletter_selection' );

  • weezie
    • Flash Drive

    Hi! Thanks for this reply. I have it in my functions.php- the field does show up on the confirmation form on the site. However, I cannot find where the information goes once submitted. It isn’t showing up after the submission. Any suggestions?

  • aecnu
    • WP Unicorn

    Greetings weezie,

    Thank you for your additional input and I will alert the lead developer @vladislav to the fact that you have indeed made additional input into this ticket and hoepfully he will be able to clarify this for us.

    Hopefully while making his rounds he will make it in here sooner then later.

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.