Setup your WordPress to allow guests to create a blog post on your blog

In this post, I will create a detailed tutorial on how to setup your WordPress to allow guests to create a blog post on your WordPress blog. You can off course choose to have the posts go in pending or published mode.

Assuming you have a WordPress site live and you have the Exec-PHP Plugin installed

First we will create a simple Page from WP-Admin Page System.
In this new page, we will create a HTML form. I will give this page a name as ADD ARTICLE. In the page body, use the below HTML code.

In the above code, you can see the form action is set to a permalink function which calls the full URL of the page which will process the post submission. The ID 23 will be replaced by your actual page ID. I will explain that procedure in the next steps.

Currently we have Post Title, Post Body or Content and Post Category fields in the above form. The form has category selection box which allows you to select multiple categories at the same time.

Now, we have to create a the submission routine in another PHP file and we will set it up as a WordPress page online.

Go to WP-Admin > Pages > Add New
Enter the Page title whatever you like. For mine, I would say “Add Article Result”
In the body, select the HTML tab from right top of the editor and paste the PHP code below

In the above PHP code, I have also described a few things via PHP comments near the actual code. The my_post is an array and stores all the variables received from the posted form. The post_status I set to draft so it doesn’t publish the post immediately. However if you want it to do that, you can change the value from draft to publish.

The function wp_insert_post runs the query and saves all the data of post in the WordPress database. And finally, the last echo line simply shows the confirmation of the submission.

This is a very easy and quick procedure in order to get this kind of task done. However there are more optimized and secure ways can be done for this kind of requirements.

Hope it helps.

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.