Hi
Please can you help, if the product being paid for has the product ID 48460 or the price is zero then do not assign the (Sponsored Post) category.
/** * Assign (Sponsored Post) category to BuddyBlog pay per post articles on checkout. */ function assign_sponsored_term_on_purchase( $post_id ) { // Ensure this is a post type 'post' $post_type = get_post_type( $post_id ); if ( 'post' !== $post_type ) { return; } // Get the taxonomy term 'Sponsored Posts' from 'content_type' $new_term = get_term_by( 'name', 'Sponsored Posts', 'content_type' ); if ( ! $new_term ) { return; } // Assign the term to the post wp_set_post_terms( $post_id, $new_term->term_id, 'content_type', true ); } add_action( 'bblpro_ppp_post_purchase_completed', 'assign_sponsored_term_on_purchase' );
Thanks a lot
Hi Tosin,
Thank you for the question.
We will be glad to help.Since the issue is about a premium plugin, can you share us your active subscription/order id for BuddyBlog pro? We will be glad to assist after that.
Regards
BrajeshHi Brajesh
This code seemed to work
/** * Assign (Sponsored Post) category to BuddyBlog pay per post articles using purchase meta data. */ function assign_sponsored_term_on_purchase( $post_id, $form_id = null ) { // Ensure this is a post type 'post' if ( 'post' !== get_post_type( $post_id ) ) { return; } // Check post status early - if not published, return immediately if ( 'publish' !== get_post_status( $post_id ) ) { return; } // Check if the post has any purchase-related meta data $has_purchase_meta = get_post_meta( $post_id, '_bblpro_ppp_purchased', true ); $has_expiry_time = get_post_meta( $post_id, '_bblpro_ppp_expiry_time', false ); // If the post has purchase-related meta, assume it was purchased if ( ! $has_purchase_meta && empty( $has_expiry_time ) ) { return; } // Get the taxonomy term 'Sponsored Posts' from 'content_type' $new_term = get_term_by( 'name', 'Sponsored Posts', 'content_type' ); if ( ! $new_term ) { return; } // Assign the term to the post wp_set_post_terms( $post_id, $new_term->term_id, 'content_type', true ); } add_action( 'bblpro_ppp_post_purchase_completed', 'assign_sponsored_term_on_purchase', 10, 2 );
Thanks
Hi Tosin,
Thank you for sharing. I am glad it is working for you.Regards
Brajesh
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
This topic is: not resolved