Support » Plugin: Post My CF7 Form » Unexpected Error

  • Resolved alexmkubik

    (@alexmkubik)


    add_filter('cf7_2_post_filter-group-editor','filter_group_editor',10,3);
    function filter_group_editor($value, $post_id, $form_data){
      //$value is the post field value to return, by default it is empty. If you are filtering a taxonomy you can return either slug/id/array.  in case of ids make sure to cast them integers.(see https://codex.wordpress.org/Function_Reference/wp_set_object_terms for more information.)
      //$post_id is the ID of the post to which the form values are being mapped to
      // $form_data is the submitted form data as an array of field-name=>value pairs
       $value = '<div id="form-field-content">';
          if(isset($form_data['facilitator-name']){
            $value .= '<p>Field: '. $form_data['facilitator-name'] . '</p>';
          }
          if(isset($form_data['facilitator-email']){
            $value .= '<p>Field: '. $form_data['facilitator-email'] . '</p>';
          }
          if(isset($form_data['facilitator-phone']){
            $value .= '<p>Field: '. $form_data['facilitator-phone'] . '</p>';
          }
          if(isset($form_data['group-link']){
            $value .= '<p>Field: '. $form_data['group-link'] . '</p>';
          }
    	  if(isset($form_data['group-affiliation']){
            $value .= '<p>Field: '. $form_data['group-affiliation'] . '</p>';
          }
    	  if(isset($form_data['group-location']){
            $value .= '<p>Field: '. $form_data['group-location'] . '</p>';
          }
    	  if(isset($form_data['group-address']){
            $value .= '<p>Field: '. $form_data['group-address'] . '</p>';
          }
    	  if(isset($form_data['group-desc']){
            $value .= '<p>Field: '. $form_data['group-desc'] . '</p>';
          }
    	  if(isset($form_data['meet-freq']){
            $value .= '<p>Field: '. $form_data['meet-freq'] . '</p>';
          }
    	  if(isset($form_data['meet-day']){
            $value .= '<p>Field: '. $form_data['meet-day'] . '</p>';
          }
    	  $value .= '<div/>';
      return $value;
    }

    Getting an unexpected error on the { bracket in the very first if(isset line…

    Thoughts?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • PROGRESS:

    SO the auto-generated hook is missing a close parenthesis in each isset…

    if(isset($formdata[])){

    One to close the if, another to close the isset.

    Now I can at least test.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    this is the auto-generated hook code:

    add_filter('cf7_2_post_filter-group-editor','filter_group_editor',10,3);
    function filter_group_editor($value, $post_id, $form_data){
      //$value is the post field value to return, by default it is empty. If you are filtering a taxonomy you can return either slug/id/array.  in case of ids make sure to cast them integers.(see https://codex.wordpress.org/Function_Reference/wp_set_object_terms for more information.)
      //$post_id is the ID of the post to which the form values are being mapped to
      // $form_data is the submitted form data as an array of field-name=>value pairs
      return $value;
    }

    SO the auto-generated hook is missing a close parenthesis in each isset

    nope, this is your own coding mistake!

    I stand corrected. That code came from an example here in the forum, and also appears on stackexchange a few times. So for anyone fishing like I was, check the code before you borrow-copy-paste.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unexpected Error’ is closed to new replies.