• phpnukes

    (@phpnukes)


    Is it possible to use the form to submit content into the posts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Jainil Nagar

    (@jainilnagar)

    Hello @phpnukes

    You can apply the hook and get form data that use that to create a new post.

    add_action('wpcf7_before_send_mail','insert_new_post',10,3);
    
    function insert_new_post( $contact_form, $abort, $submission ) {
    
    	if( $contact_form->id() == 'YOUR_FORM_ID' ) {
    		// Get Submitted post data.
    		$data = $submission->get_posted_data();
    	
    		$name = $data[ 'your-name' ];
    
    		//Post Insert Code
    	}
    	
    }

    See Accessing user input data

    rapidasia

    (@rapidasia)

    if php ain’t your thing, search WordPress repository for ” CF7 ” there is a plugin that does what you’re asking for

    Thread Starter phpnukes

    (@phpnukes)

    Jainil
    Thank you for your time, response and input here.
    Love php need to do a bit of a catch up. It’s been a very long time since I played with coding.
    Been using WordPress since 1996 clearly getting into lazy habits.

    Looking at the code snippet this goes into the post function file?

    With upgrades in the plug-in or WordPress would be affected?

    This is why plug-ins are much easier than having to update the code in future upgrades.

    Thank you

    Jainil Nagar

    (@jainilnagar)

    Hello @phpnukes

    Yes, this code needs to add to the theme’s functions.php file.

    With upgrades in the plug-in or WordPress would be affected?
    >>> This depends on your code. The CF7 hook and function will be the same.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using contact form to post into posts’ is closed to new replies.