Skip to main content

Create Article / CPT Integration

Create a blog post or custom post type entry with full field mapping, taxonomy assignment, ACF field support, and featured image handling.

Action type: create_article Class: Core_Forms\Actions\CreateArticle Source: src/actions/class-create-article.php

Setup

  1. Edit your form > Actions tab > Add Action > Create Article / CPT.
  2. Select the post type and status.
  3. Map form fields to post fields, taxonomies, ACF fields, and meta.

Settings Reference

Setting Required Default Description
Post Type No post Any registered public post type
Post Status No draft draft, pending, publish, or private
Title Template No -- Template with [field] variables
Title Field No -- Form field for the title (overrides template)
Content Field No -- Form field for post content (supports HTML)
Content Template No -- Template with [field] variables (used if Content Field is empty)
Excerpt Field No -- Form field for the post excerpt
Slug Field No -- Form field for the post slug
Author Email Field No -- Assign post to the WP user matching this email
Featured Image Field No -- File upload field or URL field for the featured image
Taxonomy Mapping No -- Map form fields to taxonomies
ACF Field Mapping No -- Map form fields to ACF fields
Custom Meta Fields No -- Map form fields to post meta keys

Title Resolution

Priority order: 1. Title Field -- uses the field value directly 2. Title Template -- processes [field] variables (e.g., [name] -- [subject]) 3. Fallback -- {Form Title} -- {timestamp}

Content Resolution

Priority order: 1. Content Field -- uses the field value (HTML via wp_kses_post()) 2. Content Template -- processes [field] variables and HTML 3. Fallback -- auto-generated from all fields with bold labels

Author Assignment

If Author Email Field is set, the post is assigned to the WordPress user matching that email. If no user is found, falls back to the current user (or user ID 0 for anonymous submissions).

Featured Image

The Featured Image Field handles two scenarios: - File upload field: Uses the existing attachment_id from the upload - URL field: Sideloads the image via media_sideload_image() and sets it as the featured image

Taxonomy Mapping

One mapping per line, form_field=taxonomy_name:

category_field=category
tag_field=post_tag
genre_field=genre

Term resolution order for each value: 1. Numeric value -- looked up as term ID 2. String -- looked up as slug 3. String -- looked up as name 4. If not found -- auto-creates the term

Multiple terms are supported via comma-separated values or array fields (checkboxes).

ACF Field Mapping

One mapping per line, form_field=acf_field_name:

email=contact_email
rating=review_score
bio=author_biography
cover=cover_image

Uses update_field() for proper ACF storage with serialized meta keys. The admin UI auto-detects ACF field groups for the selected post type and displays available fields in a collapsible reference table.

Supported ACF Field Types

The integration auto-detects the ACF field type and converts values accordingly:

ACF Type Handling
text, email, url, password, color Sanitized as text
textarea, wysiwyg Allowed HTML via wp_kses_post()
number, range Cast to float
true_false Converts 1, yes, true, on to 1, everything else to 0
select, radio, button_group String value; arrays for multi-select
checkbox Array of values (splits comma-separated strings)
date_picker Converts to Ymd format
date_time_picker Converts to Y-m-d H:i:s format
time_picker Stored as-is
image, file Attachment ID from upload field, or sideloads from URL
gallery Array of attachment IDs
taxonomy Array of term IDs
post_object, relationship Post ID(s); single or array based on field config

Custom Meta Mapping

One mapping per line, form_field=meta_key (for non-ACF custom fields):

phone=_contact_phone
company=_company_name

File upload fields store the attachment_id. Array values are comma-joined.

Hook: cf_article_created

Fires after the post is created with all mappings applied:

add_action( 'cf_article_created', function( $post_id, $submission, $form, $settings ) {
    // Custom logic after article creation
    update_post_meta( $post_id, '_custom_flag', 'processed' );
}, 10, 4 );

Parameters: $post_id (int), $submission (Submission), $form (Form), $settings (array).

Submission Reference

Every created post stores _cf_submission_id as post meta, linking back to the submission.

Example: Guest Article Submission

Form with title, content, excerpt, category, tags, and author_image fields:

  • Post Type: post
  • Post Status: pending
  • Title Field: title
  • Content Field: content
  • Excerpt Field: excerpt
  • Featured Image Field: author_image
  • Taxonomy Mapping: category=category tags=post_tag

Example: Product Submission with ACF

Form with product_name, price, description, sku, and product_image fields:

  • Post Type: product
  • Post Status: draft
  • Title Field: product_name
  • Content Field: description
  • ACF Field Mapping: price=product_price sku=product_sku product_image=product_gallery

Troubleshooting

  • ACF fields not saving: Ensure ACF is active and update_field() is available. The ACF field name must match exactly.
  • Taxonomy terms not found: Terms are auto-created if they do not exist. Check that the taxonomy is registered for the selected post type.
  • Featured image not set: For URL fields, the image must be a valid, accessible URL. For file uploads, ensure the upload extension is active.
  • ACF mapping not shown: The ACF field mapping UI only appears if ACF is installed and active.