<p>You can use the <a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">FrontEnd Entry Form</a> for this. If you want to allow guests (non-registered users) to submit the form, you need to use the <a href="https://github.com/pixelandtonic/GuestEntries" rel="nofollow">Guest Entries plugin</a>.</p>

<p>Both methods will set "publishing date, id, etc" automatically, you just need to specify the title in the form.</p>

<p>If you want to hard-code some field values and prevent the user from changing it, you'd need to create a plugin which checks for <a href="http://buildwithcraft.com/docs/plugins/events-reference#entries-onBeforeSaveEntry" rel="nofollow"><code>entries.onBeforeSaveEntry</code></a> or <a href="https://github.com/pixelandtonic/GuestEntries#the-guestentriesbeforesave-event" rel="nofollow"><code>guestEntries.beforeSave</code></a> (if you use Guest Entries plugin).</p>

<p><strong>Edit:</strong></p>

<p>The Entry Form is just an example. You can just as well use an ajax-request to send your data. Just make sure the POST values are set correctly.</p>

<p>If you want to save an entry from within your plugin, use the <a href="http://buildwithcraft.com/docs/apis/entriesservice" rel="nofollow">EntriesService API</a></p>

CC BY-SA 3.0
2014-07-15T02:48:43.213Z
Hey sorry I noticed a mistake in my question. The reason I cant use the entry form is because I am using another plugin the creates a shopping cart for the user and then sends that data to another site on checkout. The plugin is simplecart js and it requires that my fields be entered in divs instead of a form input. So in the end I do have the data but I have it in a php array inside my own plugin. Is there a way to create a new entry and save it using data from this array?
Moin Qidwai
CC BY-SA 3.0
2014-07-15T11:50:58.157Z
Sure, edited my answer.
Victor
CC BY-SA 3.0
2014-07-14T11:06:53.923Z
2014-07-15T11:50:27.177Z
2014-07-15T11:50:27.177Z
Victor
<p>I have a channel section by the name of order. What I need is that every time a user clicks a button on the front end the data of the form is sent to my plugin which then uses the data to create a new entry of type order and saved in the back end. The data in the form only represents the content of the entry and the only other information we have is that the entry is of type channel and that it belongs to the order channel. What would be the best way to create the entry with the publishing date, title, id, etc all set appropriately? Can I use saveEntry of the entries service in some way?</p>

CC BY-SA 3.0
2014-07-14T16:32:52.293Z
Hi @Moin! Just for reference, there's a [post here](http://craftcms.stackexchange.com/questions/33/how-do-you-create-a-front-end-form-for-users-to-submit-content/35#35) with more detail on using the Guest Entries plugin Victor referred to.
Matt Stein
<plugin-development><entries><services>
Whats the best way to save a new entry in my plugin?
# Whats the best way to save a new entry in my plugin?

(Asked by: username_0 on 2014-07-14)

I have a channel section by the name of order. What I need is that every time a user clicks a button on the front end the data of the form is sent to my plugin which then uses the data to create a new entry of type order and saved in the back end. The data in the form only represents the content of the entry and the only other information we have is that the entry is of type channel and that it belongs to the order channel. What would be the best way to create the entry with the publishing date, title, id, etc all set appropriately? Can I use saveEntry of the entries service in some way?

**Tags:** plugin-development, entries, services

> **Comments:**
> **username_1**: Hi @Moin! Just for reference, there's a [post here](http://craftcms.stackexchange.com/questions/33/how-do-you-create-a-front-end-form-for-users-to-submit-content/35#35) with more detail on using the Guest Entries plugin username_2 referred to.  

---

## 1 answers

### Answer by username_2 on 2014-07-14. Score: 3

You can use the [FrontEnd Entry Form](http://buildwithcraft.com/docs/templating/entry-form) for this. If you want to allow guests (non-registered users) to submit the form, you need to use the [Guest Entries plugin](https://github.com/pixelandtonic/GuestEntries).

Both methods will set "publishing date, id, etc" automatically, you just need to specify the title in the form.

If you want to hard-code some field values and prevent the user from changing it, you'd need to create a plugin which checks for [`entries.onBeforeSaveEntry`](http://buildwithcraft.com/docs/plugins/events-reference#entries-onBeforeSaveEntry) or [`guestEntries.beforeSave`](https://github.com/pixelandtonic/GuestEntries#the-guestentriesbeforesave-event) (if you use Guest Entries plugin).

**Edit:**

The Entry Form is just an example. You can just as well use an ajax-request to send your data. Just make sure the POST values are set correctly.

If you want to save an entry from within your plugin, use the [EntriesService API](http://buildwithcraft.com/docs/apis/entriesservice)

> **Comments:**
> **username_0**: Hey sorry I noticed a mistake in my question. The reason I cant use the entry form is because I am using another plugin the creates a shopping cart for the user and then sends that data to another site on checkout. The plugin is simplecart js and it requires that my fields be entered in divs instead of a form input. So in the end I do have the data but I have it in a php array inside my own plugin. Is there a way to create a new entry and save it using data from this array?  
> **username_2**: Sure, edited my answer.  

---

