• Resolved sinebyte

    (@sinebyte)


    Hello,

    I wonder if it is possible to submit a form entry from my own code to utilize cf7 mail/ other addon features?

    I do not care about field validation or the front end form etc.

    Using php can I use a static function with object or do i still need to POST the data, can I use REST endpoint from server side?

    I have been using gravity forms which allows you build a form submission object/array and use the static method: $entry_id = GFAPI::add_entry( $entry );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sinebyte

    (@sinebyte)

    
    function mde_send_post_request(){
    	$url = 'https://localhost/wp-json/contact-form-7/v1/contact-forms/181/feedback';
    	$response = wp_remote_post( $url, array(
        'method' => 'POST',
        'headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded' ),
        'body' => array( 
    		'your-name' => 'user',
    		'your-email' => '[email protected]',
    		'your-subject' => 'hello',
    		'your-message' => 'whats happening',
    		)
        ));
    	return $response;
    }
    
    • This reply was modified 4 years, 1 month ago by sinebyte.

    Hello @sinebyte,

    Thanks for share the code with the solution!

    Best regards,
    Yordan.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I create a form submission via code’ is closed to new replies.