Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created November 26, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/eb2225b17a95e78d31978df55e356960 to your computer and use it in GitHub Desktop.
Save jaredatch/eb2225b17a95e78d31978df55e356960 to your computer and use it in GitHub Desktop.
WPForms
<?php
/**
* WPForms automatically add category to posts created with post submission addon.
*
* @param int $post_id Post ID of the new post created
* @param array $fields
* @param array $field_data
* @param int $entry_id
*/
function wpf_post_submissions_add_category( $post_id, $fields, $form_data, $entry_id ) {
// Auto assign the category with the ID of 6
wp_set_post_categories( $post_id, array( 6 ) );
}
add_action( 'wpforms_post_submissions_process', 'wpf_post_submissions_add_category', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment