Support » Plugin: Better Notifications for WP » Front end submission solution

  • Resolved WPwebbouw

    (@wpwebbouw)


    I use Toolset Forms to publish custom post type posts from the front end. A notification that should fire when these posts are published did not fire. I tried the solution described on https://betternotificationsforwp.com/documentation/compatibility/support-plugins-front-end-forms/
    add_filter( 'bnfw_trigger_insert_post', '__return_true' ); but this did not solve the problem. Then I got the idea to submit the posts as draft and then use an api-call from the Toolset Cred form to change the post status from draft to publish. This worked! I publish the code I used here for anyone who runs into the same issue.

    // use cred api call to change post status
    // https://toolset.com/documentation/programmer-reference/cred-api/
    // https://wordpress.stackexchange.com/questions/12512/how-to-update-page-status-from-publish-to-draft-and-draft-to-publish
    add_action('cred_submit_complete', 'my_success_action',10,2);
    function my_success_action($post_id, $form_data)
    {
        // if a specific form (change the $form_data['id'] value to the one of your form)
        if ($form_data['id']==5627)
        {
            // user can overwrite everything here, eg redirection, messages displayed etc..
            $cur_post = array( 'ID' => $post_id, 'post_status' => 'publish' );
    	wp_update_post($cur_post);
        }
    }
    
    • This topic was modified 9 months ago by WPwebbouw.
    • This topic was modified 9 months ago by WPwebbouw.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Front end submission solution’ is closed to new replies.