BNFW / Anspress Integration

5.58K viewsCoreBNFW notifications
0

I’m trying to get a Better Notifications For WordPress, which is being used for my blog Posts to also work with Anspress Questions. Its my understanding that the Question is just another post type, and its confirmed by BNFW, as its able to be selected as a post type.
However, its not firing off a notification when submitting a new Question. BNFW uses post transitions to fire off their notifications… some helpful information can be found in this thread: https://wordpress.org/support/topic/duplicate-notifications-6/
I’m currently looking at class-form-hooks.php around lines 425 in order to try to generate a post transition.
Its currently not working, and if I try to use wp_update_post() I get an error message about a duplicate question. And I don’t think I have access to $wpdb->update() in this static method.
Can you provide any direction or help with this integration?

Answered question
1

This solved it:
includes\class-form-hooks.php

if ( ! $editing ) {
     $question_args['post_type'] = 'question';
            $question_args["post_status"] = "draft";
            $post_id = wp_insert_post( $question_args, true );
            $postToTransition = ap_get_post( $post_id );
            ap_updatePost("publish", $postToTransition);
            wp_transition_post_status( "publish", "draft", $postToTransition);
}


And
includes\functions.php

function ap_updatePost( $newStatus, $post )
{
    global $wpdb;
    $wpdb->update($wpdb->posts, array('post_status' => $newStatus), array('ID' => $post->ID));
}

Posted new comment

Good to know

You are viewing 1 out of 2 answers, click here to view all answers.