BuddyDev

Search

[Resolved] Buddyblog hook question

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #47842

    Hello,

    Please i have this code

     function revoke_ngx_points_after_post_deletion( $post_id ) {
      // Get the post type of the post
      $post_type = get_post_type($post_id);
      
      // Check if the post type is "post" or "advert"
      if ($post_type == 'post' || $post_type == 'advert') {
        // Get the user ID of the post author
        $user_id = get_post_field('post_author', $post_id);
        
        // Get the rating of the post
        $rating = rmp_get_avg_rating( $post_id );
        
        // Check if the rating is 4 or 5 stars
        if ($rating == 4 || $rating == 5) {
          // Revoke the points awarded to the user for this post
          gamipress_deduct_points_to_user( $user_id, 0, 'ngx-tokens', 'All star rating tokens have been deducted for deleting a post' );
        }
      }
    }
    add_action( 'deleted_post', 'revoke_ngx_points_after_post_deletion', 10, 1 ); 

    I would like to confirm if (deleted_post) is the correct hook meant to be used for buddyblog pro

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #47847

    Hi Tosin,

    Thank you for the question.
    The hook is correct. BuddyBlog posts are normal WordPress posts and the same hook works for both.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #47861

    Thanks this is now resolved

You must be logged in to reply to this topic.

This topic is: resolved