Tagged: Buddyblog Pro Pay Per Post
- This reply has been marked as private.
- This reply has been marked as private.
Hello Ravi,
Please can you take a look at this rough work
function wp_set_post_category( $post_id, $post_categories, $append ) { if ( $parent = wp_is_post_revision( $post_id ) ) $post_id = $parent; $post = get_post( $post_id ); if ( $post->post_type != 'post' ) return; // add a category $categories = wp_get_post_category( $post_id ); $newcat = get_term_by( 'name', 'Sponsored posts', 'category' ); array_push( $categories, $newcat->term_id ); wp_set_post_category( $post_id, $categories ); } do_action( 'bblpro_ppp_post_published', $post_id, $form_id );
Thanks
- This reply was modified 2 years, 9 months ago by Tosin.
or this
function wp_set_post_categories( $post_id, $post_categories, $append = true ) { if ( $post->post_type != 'post' ) return; // add a category $categories = wp_get_post_categories( $post_id ); $newcat = get_term_by( 'name', 'Sponsored posts', 'category' ); array_push( $categories, $newcat->term_id ); wp_set_post_categories( $post_id, $categories ); } do_action( 'bblpro_ppp_post_published', $post_id, $form_id );
Hello Tosin,
Try the following code:
add_action( 'bblpro_ppp_post_published', function( $post_id ) { $post_type = get_post_type( $post_id ); if ( 'post' != $post_type ) { return; } // Get category. $newcat = get_term_by( 'name', 'Sponsored posts', 'category' ); if ( ! $newcat ) { return; } wp_set_post_categories( $post_id, $newcat->term_id, true ); } );
Please check and let me know if it helps or not.
Regards
Ravi
The topic ‘ [Resolved] Pay Per Post by selling access with WooCommerce’ is closed to new replies.
This topic is: resolved