The Post Management Action on WS Form

Post ManagementPRO

This knowledge base article relates to the WS Form Post Management add-on. Click here to purchase this add-on.

The ‘Post Management’ action allows you to create forms and add actions for creating and updating posts of any post type in WordPress.

For example you could create a form for adding a:

  • Post
  • Page
  • Custom Post Type

You can also populate a form using post data.

About WordPress Post Records

Post records are the heart of WordPress. They are used for storing blog articles, revisions and comments and are also used by other plugins such as WooCommerce for storing order information.

In WordPress, there are two tables in the database that store information about posts. The wp_posts table stores basic information about posts (title, date added etc), whereas the wp_postmeta table is used to store additional information about them, for example, custom fields that you create yourself.

The ability to manage custom posts fields is not native to WordPress so you will need to use a plugin to configure them. We recommend using the Advanced Custom Fields (ACF) plugin. To learn more about using WS Form with ACF, click here.

The WS Form Post Management add-on allows you to create and edit post meta data by mapping your form fields to meta keys.

Creating A Post Management Form

Automatically (Recommended)

WS Form can create a form for any of the post management functions in a single click. This process not only creates a form but also fully configures WS Form so that the form is ready to use immediately.

To create a post management form in WS Form:

  1. Click ‘WS Form’ in the WordPress administration menu.
  2. Click ‘Add New’.
  3. Select the ‘Post Management’ tab at the top of the page.
  4. Click on the post type you would like to create a form for.
  5. Wait a few moments while the form is created.

That’s it! Your form will be created and is ready to add to your website.

Tip: We recommend using the automatic method. Not only does this method create the form for you, but it also maps the fields and creates checkboxes for taxonomies associated with the post type you selected.

Manually

It is also possible to use any form created in WS Form and add an action so that it is creates a post when a user saves or submits their form.

To add a post management action:

  1. When editing your form, click the ‘Actions’ icon at the top of the page. The ‘Actions’ sidebar will open on the right hand side of the page.
  2. Click the ‘Add’  icon to add a new action.
  3. Select ‘Post Management’ from the Action pulldown. A series of settings will appear.

As with all sidebars in WS Form, click to the ‘Save’ button at the bottom to save your changes, or click ‘Cancel’ to disregard your changes.

The post management action settings are as follows:

When Should This Action Run?

You can choose to add the post when the form is saved, submitted, or both.

Post Type

Choose the type of post you would like to create.

Post ID

If this setting is blank, a new post will be created.

If this setting is not blank, the value entered should be the post ID that you wish to update.

You can enter WS Form variables in this field. Variables in this setting are parsed once the form has been submitted.

Here are some examples of values you can enter into this field:

Post ID Description
123 Update the post or page with the ID: 123. This method is a good way of testing post updates.
#post_id Update the post or page that the form is shown on. The #post_id variable returns the ID of the current post or page.
#field(456) Use the submitted value of field ID: 456 as the post ID to update. For example, if field ID 456 is a hidden field with the number 123 in it, post ID 123 would be updated.
Passing the Post ID as a Query Variable

It is possible to specify the post ID you wish to update as a variable in a query string. For example:

https://mysite.com/my-form-page/?post_id=12345

This example would push the submitted form to post ID 12345.

To do this:

  1. Add a hidden field to your form.
  2. Set the ‘Default Value’ setting to #query_var("post_id").
  3. In the Post Management action, enter #field(123) in the Post ID setting. Change ‘123’ to the ID of the hidden field you added.

You can combine this with Auto Populate under Form Settings to create a post editing feature.

Field Mapping

Field mapping tells WS Form which of your form fields relate to the corresponding post being created.

To map a field:

  1. Click the ‘Add’  icon at the bottom right of the field mapping section.
  2. In the left-hand column, select your form field.
  3. In the right-hand column, select the corresponding post field.
  4. Repeat this process for each field on your form.
  5. Click the ‘Save’ button at the bottom of the sidebar to save your changes.
Field Meta Mapping

The add-on also supports mapping fields to post meta data.

To map a field to meta data:

  1. Click the ‘Add’  icon at the bottom right of the meta mapping section.
  2. Select your form field.
  3. Select the meta key you would like to create using the form field.
  4. Repeat this process for each field on your form.
  5. Click the ‘Save’ button at the bottom of the sidebar to save your changes.
Custom Meta Mapping

The add-on also supports setting custom meta keys to values.

To add a meta key-value pair:

  1. Click the ‘Add’  icon at the bottom right of the meta mapping section.
  2. Enter the meta key you would like to set a value for.
  3. Enter the meta value you would like to set the meta key to.
  4. Repeat this process for each meta key-value pair.
  5. Click the ‘Save’ button at the bottom of the sidebar to save your changes.
Deduplication by Field

You can avoid deduplication by specifying which of your form fields you want to be unique for the post type being created.

To specify a field that you do not want duplicates for:

  1. Click the ‘Add’  icon at the bottom right of the deduplication by field section.
  2. Select your form field.
  3. Repeat this process for each field on your form that you do not want duplicates for.
  4. Click the ‘Save’ button at the bottom of the sidebar to save your changes.
Attachment Mapping

File and signature fields can be mapped so that they are uploaded as attachments to the post when it is added.

To add a file or signature field as an attachment:

  1. Click the ‘Add’  icon at the bottom right of the attachment mapping section.
  2. Select your form field.
  3. Repeat this process for each field on your form that you want to include as an attachment.
  4. Click the ‘Save’ button at the bottom of the sidebar to save your changes.

File fields that are marked as multiple will result in multiple attachments if more than one file is uploaded.

Featured Image

Select a file or signature field you would like to use for uploading a featured image. The file will be uploaded to the media library and also assigned as the post’s featured image.

Term Mapping

You can also assign terms to the post that is created. These include:

  • Post categories
  • Post tags
  • Custom taxonomies

We recommend using a choice field for term mapping, such as checkboxes.

For hierarchical terms you should make sure the submitted value is the ID of the term. You can do this by ensuring your checkbox data grid has two columns, one called ‘Values,’ which would contain the term IDs, and another column called ‘Labels,’ which would contain the term names.

For non-hierarchical terms, such as tags, you should make sure the submitted value is just the name of terms.

To specify which fields are used to assign terms to a post:

  1. Click the ‘Add’  icon at the bottom right of the term mapping section.
  2. Select the taxonomy the form field relates to.
  3. Select your form field.
  4. Repeat this process for each field on your form that you want to map as containing terms.
  5. Click the ‘Save’ button at the bottom of the sidebar to save your changes.
Status

Select the status you would like the newly created post to have.

Status Description
Publish Post is viewable by everyone.
Scheduled Scheduled to be published in a future date.
Draft Incomplete post viewable by anyone with proper user role.
Pending Awaiting a user with the appropriate capability to publish.
Private Viewable only to WordPress users at Administrator level.
Author

Select the author of the post. This defaults to the current user signed into the website.

Restrict Updates to Author

By checking this setting, updates to posts will be restricted so that only the original author can update their own post. That user will need to be signed in to update their post.

Comment Status

Select whether the post can accept comments.

Ping Status

Select whether the post can accept pings.

Date

Enter the date of the post. Leave blank for current time.

Error Messages

WS Form PRO processes any error messages received from WordPress as standard WS Form messages. The error message settings match those of the ‘Show Message‘ action. You can configure these options to change how the error messages are displayed to users.