Essentials
Filters

Event Filters add additional conditions or actions to an event.

Description

Success and Failure XML Examples

When saved successfully, the following XML will be returned:

<publish-article result="success" type="create | edit">
  <message>Entry [created | edited] successfully.</message>
</publish-article>

When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned:

<publish-article result="error">
  <message>Entry encountered errors when saving.</message>
  <field-name type="invalid | missing" />
  ...
</publish-article>

The following is an example of what is returned if any filters fail:

<publish-article result="error">
  <message>Entry encountered errors when saving.</message>
  <filter name="admin-only" status="failed" />
  <filter name="send-email" status="failed">Recipient username was invalid</filter>
  ...
</publish-article>

Example Front-end Form Markup

This is an example of the form markup you can use on your frontend:

<form method="post" action="" enctype="multipart/form-data">
  <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
  <label>Title
    <input name="fields[title]" type="text" />
  </label>
  <label>Body
    <textarea name="fields[body]" rows="20" cols="50"></textarea>
  </label>
  <label>Date
    <input name="fields[date]" type="text" />
  </label>
  <input name="fields[categories]" type="hidden" value="..." />
  <label>Publish
    <input name="fields[publish]" type="checkbox" />
  </label>
  <input name="action[publish-article]" type="submit" value="Submit" />
</form>

To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:

<input name="id" type="hidden" value="23" />

To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:

<input name="redirect" type="hidden" value="http://example.com/success/" />