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.

How to get entry or form value from field with underscore

  1. Hello,

    When I set up WPGeo, it had me create two fields for lat/long, labeled like this:

    _wp_geo_latitude
    _wp_geo_longitude

    I'm trying to access those values using gform_post_submission, but I'm not getting anything the normal way, $entry[32]. Is there something special about using an underscore? Can I access this value another way?

    Thanks,
    Casey

    Posted 13 years ago on Sunday July 17, 2011 | Permalink
  2. There is nothing special about the underscore fields. The underscore just hides them from the custom fields drop down in the post editor. Please post a link to your form and the code you're using so we can see where the problem might lie.

    Posted 13 years ago on Sunday July 17, 2011 | Permalink
  3. Hello,

    Here's a link to my form:

    http://pcsreports.com/submit-review

    The hidden field I'm trying to get the value for is 6_32 and I'm referencing it in my code as:

    add_action("gform_post_submission_6", "create_cat");
    function create_cat($entry, $form){
    	//add coords to category meta
    	function add_coords($cat_id) {
    		add_terms_meta($cat_id['term_id'], 'category_meta_latitude', $entry[32]);
    	}
    ... lots of other code
    }
    Posted 13 years ago on Monday July 18, 2011 | Permalink
  4. Hi Caseym,

    Try using the print_r() function to output the entire $entry array and see if there is a value for that index at all. If there is no value stored, could you explain how the hidden field is populated? I was not clear on that.

    Posted 13 years ago on Monday July 18, 2011 | Permalink
  5. David,

    I found the problem and it's nothing related to gravity forms. I was trying to call $entry[32] within a function. But when I passed the value to the function it worked:

    function add_coords($cat_id, $coord_input) {
    		add_terms_meta($cat_id['term_id'], 'category_meta_latitude', $coord_input);
    	}
    add_coords($named_id, $entry[32]);
    Posted 13 years ago on Tuesday July 19, 2011 | Permalink

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