Replies
This is the code that worked for me
/** * Assign "Sponsored Posts" content type if post is marked as sticky. */ function assign_sponsored_term_if_sticky( $post_id, $form_id, $post_data ) { // Check if post is sticky. if ( ! is_sticky( $post_id ) ) { return; } // Get the "Sponsored Posts" term in 'content_type' taxonomy. $term = get_term_by( 'name', 'Sponsored Posts', 'content_type' ); if ( ! $term || is_wp_error( $term ) ) { return; } // Append the term to the post without removing other terms. wp_set_post_terms( $post_id, array( $term->term_id ), 'content_type', true ); } add_action( 'bblpro_post_submitted', 'assign_sponsored_term_if_sticky', 20, 3 ); add_action( 'bblpro_post_updated', 'assign_sponsored_term_if_sticky', 20, 3 );
I dont know why this code below did not work
/** * Reassign "Sponsored Posts" term when a paid post is submitted or updated. */ function assign_sponsored_term_if_paid( $post_id, $form_id, $post_data ) { // Check if the post is paid. if ( ! bbl_ppp_get_post_order_id( $post_id ) ) { return; } // Get the "Sponsored Posts" term. $term = get_term_by( 'name', 'Sponsored Posts', 'content_type' ); if ( ! $term ) { return; } // Append the term without removing existing ones. wp_set_post_terms( $post_id, array( $term->term_id ), 'content_type', true ); } add_action( 'bblpro_post_submitted', 'assign_sponsored_term_if_paid', 20, 3 ); add_action( 'bblpro_post_updated', 'assign_sponsored_term_if_paid', 20, 3 );
Thanks Brajesh
This is the code I used can you confirm if its accurate
/** * Assign (Sponsored Post) category to BuddyBlog pay per post articles on checkout. */ function assign_sponsored_term_if_paid( $post_id, $form_id ) { if ( 'post' !== get_post_type( $post_id ) ) { return; } // Check if post is a paid post by checking if order ID exists. $order_id = get_post_meta( $post_id, '_bblpro_ppp_order_id', true ); if ( ! $order_id ) { return; } // Get the Sponsored Posts term. $term = get_term_by( 'name', 'Sponsored Posts', 'content_type' ); if ( ! $term || is_wp_error( $term ) ) { return; } // Assign Sponsored Posts term to the post (merge with existing). wp_set_post_terms( $post_id, array( $term->term_id ), 'content_type', true ); } add_action( 'bblpro_post_submitted', 'assign_sponsored_term_if_paid', 20, 2 ); add_action( 'bblpro_post_updated', 'assign_sponsored_term_if_paid', 20, 2 );
Thanks
1. I created a custom taxonomy called CONTENT TYPE where by (Sponsored Posts) is an option.
2. I now disabled the (Sponsored Posts) option in the buddyblog settings because I don’t want users to be select this option when posting.
3. I only want the (Sponsored Posts) option to be automatically assigned only to featured paid post using the code I shared above. IM USING PAY PER POST ADDON
THE PROBLEM
1. The problem now is with the retention/removal of the (Sponsored Posts) term to published paid post when users try to edit and republish a paid post.
2. If I edit a paid post the (Sponsored Posts) term is removed after clicking the (UPDATE) button.
3. When editing a paid post the term (Sponsored Posts) should not be removed as the term was initially assigned using the code I provided
Gentle reminder sir thanks
- Tosin on January 15, 2025 at 3:50 pm in reply to: [Resolved] How to disable wordpress/buddypress new user email #54665
Thanks Brajesh
Your code worked perfectly.
- Tosin on January 13, 2025 at 1:29 pm in reply to: [Resolved] How to REMOVE name autocomplete and ability to message multiple people #54644
Thanks for the feedback ill stick to your advice
- Tosin on January 10, 2025 at 10:22 am in reply to: [Resolved] How to REMOVE name autocomplete and ability to message multiple people #54542
Hi Barjesh
Can you provide the same code(Limit message to one participant) for the legacy template
- Tosin on August 21, 2024 at 12:05 pm in reply to: [Resolved] Secure or hide buddypress admin users using 404 error #53049
Thanks Ravi this is now resolved
- Tosin on August 16, 2024 at 11:58 am in reply to: [Resolved] Secure or hide buddypress admin users using 404 error #53032
Thanks for the updated code
I am using the profile privacy plugin and while using your updated code I am receiving the 404 error correctly but the url is in this format https://site.com/members/mike/visibility-protected/.
I dont think it’s cool to show the (visibility-protected) slug for admins since it reveals that the admin account is available but just hidden
maybe adding the POST FORM slug parameter or form ID to the shortcode would be an option see example below
[bbl-create-by-post-type post_type=’post’ slug=’admin-post-form’]
[bbl-create-by-post-type post_type=’post’ slug=’subscriber-post-form’]