BuddyDev

Search

Buddyblog assign taxonomy on update

  • Participant
    Level: Guru
    Posts: 904
    Tosin on #55260

    Hello

    I have a custom taxonomy called content_type where by (Sponsored Posts) is a taxonomy option, now ive hidden/excluded this (Sponsored Posts) taxonomy option in the buddyblog settings but im using this code below to auto assign the (Sponsored Posts) taxonomy when a post has been paid for on checkout.

     /**
     * Assign (Sponsored Post) category to BuddyBlog pay per post articles on checkout.
     */
    add_action( 'bblpro_ppp_post_purchase_completed', function( $post_id ) {
    	$post_type = get_post_type( $post_id );
    	if ( 'post' !== $post_type ) {
    		return;
    	}
    	// Get taxonomy term.
    	$newterm = get_term_by( 'name', 'Sponsored Posts', 'content_type' );
    	if ( ! $newterm ) {
    		return;
    	}
    	// Assign term to post.
    	wp_set_post_terms( $post_id, $newterm->term_id, 'content_type', true );
    } ); 

    The problem now is if I try to edit and update the published post later, the previously assigned (Sponsored Posts) taxonomy is removed after clicking the update button

    How can I enable the previous assigned paid post to still remain intact when editing the post even though the taxonomy is hidden

  • Participant
    Level: Guru
    Posts: 904
    Tosin on #55287

    Gentle reminder sir thanks

You must be logged in to reply to this topic.

This topic is: not resolved