• Resolved mmmariaa

    (@mmmariaa)


    Can you help me?

    I have an error:

    PHP Notice: Undefined index: _wpcf7 in ****/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()’d code on line 6

    The code is:

    function send_to_crm($contact_form) {
    $result = array();
    $submission = WPCF7_Submission::get_instance() ;
    if ($submission) {
    $posted_data = $submission->get_posted_data() ;
    $form_id = $posted_data[‘_wpcf7’];

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    You’re missing a check to ensure that $posted_data actually contains a _wpcf7 key.

    You can fix this with a null coalesce operator:

    function send_to_crm( $contact_form ) {
    	$result = array();
    	$submission = WPCF7_Submission::get_instance();
    	if ( $submission ) {
    		$posted_data = $submission->get_posted_data();
    		$form_id = $posted_data['_wpcf7'] ?? 0;
    	}
Viewing 1 replies (of 1 total)
  • The topic ‘Undefined index: _wpcf7’ is closed to new replies.