Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp_new_reply not fired when bbp_insert_reply from api


  • Mickeymarko
    Participant

    @mickeymarko

    0

    I have developed an app for my website http://www.miil.co.il and part of the application is the website bbpress forum.

    now I’m adding push notification using FCM to the forum (the web site already have it) so use can get notification on mobile when a new replay is posted.

    I have been manage to send notification when replay is posted from web interface but not from the API, it seems that the bbp_new_reply is not firing when posting is done via the API.

    here is the API command.

    function bbp_api_replytotopic_post( $data ) {
    $return = array();

    //required fields in POST data
    $topic_id = bbp_get_topic_id( $data[‘id’] );
    if ( !bbp_is_topic( $topic_id ) ) {
    return new WP_Error( ‘error’, ‘Parameter value ‘ . $data[‘id’] . ‘ is not an ID of a topic’, array( ‘status’ => 404 ) );
    }

    $forum_id = bbp_get_topic_forum_id( $topic_id );
    $title = ‘RE: ‘ . bbp_get_topic_title( $topic_id );
    $content = $data[‘content’];
    $email = $data[’email’];
    $myuser = get_user_by( “email”, $email );
    $author_id = $myuser->ID;
    $new_reply_id = bbp_insert_reply(
    array(
    ‘post_parent’ => $topic_id,
    ‘post_title’ => $title,
    ‘post_content’ => $content,
    ‘post_author’ => $author_id,
    ),
    array(
    ‘forum_id’ => $forum_id,
    ‘topic_id’ => $topic_id,
    )
    );

    $return[‘id’] = $new_reply_id;
    $return[‘topic_id’] = $topic_id;
    $return[‘forum_id’] = $forum_id;
    $return[‘author_id’] = $author_id;

    return $return;
    I wonder why I do not get the same outcome from the API as the web interface, as far as I can see they are using the same function.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar