• $ctest = '<!-- wp:shortcode -->[contact-form-7 id="648b54b" title="Contact form 1"]<!-- /wp:shortcode -->';
    echo json_encode($ctest);

    When I pass contents of post in json_encode function, contact form 7 returns “Error:?Contact form not found.” Any idea why could this be happening? Is it parsing issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    What are you trying to do?

    Thread Starter Dhara Shah

    (@dharashah410)

    So I have custom plugin code written to load gallery of posts. I need to save post_content of all posts in json format to run some logic. Hence all the post object is converted to JSON using json_encode function. Because some of my blog posts have contact form 7 embeded, its returning error in console saying “Contact form not found.”.

    I was just playing around with contact form 7 code and the issue gets fixed if I modify below code to return empty string instead of error. Is there a way to override it?

    Below code is from /includes/contact-form-function.php file

    if ( ! $contact_form ) {
    		return sprintf(
    			'<p class="wpcf7-contact-form-not-found"><strong>%1$s</strong> %2$s</p>',
    			esc_html( __( 'Error:', 'contact-form-7' ) ),
    			esc_html( __( "Contact form not found.", 'contact-form-7' ) )
    		);
    	}
    Thread Starter Dhara Shah

    (@dharashah410)

    Any update on this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘json_encode() returns contact form not found error’ is closed to new replies.