Support for Themes with Front-end Forms
Sometimes, a WordPress theme will add a post directly to the database instead of transitioning it between post statuses. When this happens (usually via a front-end form of some kind), BNFW can’t pick up the notification as it passes between draft and publish, or draft and scheduled, etc.
In order to add support for your theme, please add the following code to your theme’s functions.php file, replacing the word ‘theme_name’ on line 2 with the name of your theme.
$themes = 'theme_name';
add_filter( 'bnfw_insert_post_themes', 'bnfw_insert_post_hook_for_theme' );
This isn’t always guaranteed to work but it’s a good start. If you need to add support for plugins with front-end forms, please see this help document.
Alternatively, if you’re adding your own front-end form via a template file in your theme, you can use this code snippet as a starting point:
$new_post = wp_insert_post(array(
'post_title' => $post_title,
'post_content' => $post_content,
'post_category' => $cat,
'post_status' => "draft",
'post_type' => $post_type
$post_to_transition = get_post( $new_post );
// Change the post status
$wpdb->update($wpdb->posts, array('post_status'=>'publish'), array('ID' => $post_to_transition->ID));
// Triggers the notification in BNFW
wp_transition_post_status( "publish", "draft", $post_to_transition );
Subscribe for BNFW News
Want to know when new add-ons or features are released? Sign up to the newsletter. No spam, ever. Unsubscribe at any time.