PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

passing form variables to function

  1. Hi there,
    I need to pass the variables from a massive form to a function that will register a post type with a considerable amount of custom fields etc.

    What I need to know...
    A: How to detect if a checkbox is ticked after form submission etc. I have the following code
    if($entry['22.1']) {
    add_post_meta($post_id,'customfield','value');
    }
    Will this work? Does it need to have a value in the if statement or will the $entry element be empty if not checked?

    B: How to detect the values of a radio group with 'yes' or 'no' answers and do the same thing as above. Again do I need to put in a value if statement and how would I do that? What is the structure of the $entry element on a radio group? Is it $entry['21.2'] or $entry['21_2']?
    Im guessing if there are two answers then
    yes = $entry['21.1'] or $entry['21_1']
    no = $entry['21.2'] or $entry['21_2']

    Thanks in advance for the help guys and keep up the good work, this plugin is seriously spectacular and worth every penny!!!

    Posted 13 years ago on Wednesday October 5, 2011 | Permalink
  2. Hi Tom,

    You are correct for checkboxes.

    For radio buttons, there is a single value submitted for the field (not per input) so you can check it like so:

    [php]
    if($entry[21] == 'yes') {
        // execute 'yes' code
    } else {
        // execute 'no' code
    }
    Posted 13 years ago on Wednesday October 5, 2011 | Permalink
  3. Thanks David, I'll give that a go

    Posted 13 years ago on Wednesday October 5, 2011 | Permalink

This topic has been resolved and has been closed to new replies.