BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 900

    YES im sure the anonymous user ID exists.

    1. workflow setting = on submission – publish post
    2. I also have a custom post taxonomy called (locations)
    3. redirect user to = Yes, to the single post screen.
    4. im also using the shortcode [bbl-create-by-post-type post_type=’post’] in the (create-new-post) page
    5. I also have buddyblog pay per post active

    This is all the buddyblog code I have I dont think there should be any conflict

    
     // Request confirmation before post submission.
    add_filter( 'bblpro_submission_button_classes', function ( $classes ) {
    	array_push( $classes, 'bbl-confirm-action' );
    
    	return $classes;
    } );
    
    // Buddyblog minimum words for publishing
    add_filter( 'bblpro_validation_errors', function ( $errors, $data ) {
    
    	if ( $errors->has_errors() ) {
    		return $errors;
    	}
    	$content     = empty( $data['bbl_post_content'] ) ? '' : $data['bbl_post_content'];
    	$words_count = (int) str_word_count( $content );
    
    	if ( $words_count < 100 ) {
    		$errors->add( 'bbl_post_content', _x( 'A minimum of 100 words is required to publish.', 'Post form validation message', 'buddyblog-pro' ) );
    	}
    	return $errors;
    }, 10, 2 );
    
    /**
     * Assign (Sponsored Post) category to BuddyBlog pay per post articles on checkout.
     */
    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 );
    } );
    
    /**
     * Update BuddyBlog Author when a post is submitted in a specific category.
     */
    add_filter( 'bblpro_post_submission_prepared_data', function ( $post_data, $form_id, $post, $is_submission ) {
    	// update author if the category was selected. Don't do anything on edit.
    
        $anonymous_cat_id = 1487;
        $anonymous_user_id = 4766806;
    
        if( ! $is_submission ) {
            return $post_data;
        }
    
    	$selected_terms_ids = isset( $post_data['tax_input'] ) ? (array) $post_data['tax_input'] : array();
    
    	$selected_categories = isset( $selected_terms_ids['category'] ) ? (array) $selected_terms_ids['category']: array();
    
        if( ! $selected_categories  || ! in_array( $anonymous_cat_id, $selected_categories ) ) {
            return $post_data;
        }
    
    	// Update.
    	$post_data['post_author'] = $anonymous_user_id;
    	// keep current user data for future?
    	if ( ! empty( $post_data['ID'] ) ) {
    		update_post_meta( $post_data['ID'], '_bbl_original_post_author', get_current_user_id() );
    	}
    
    	return $post_data;
    }, 10, 4 );
    
  • Participant
    Level: Guru
    Posts: 900

    I just tested the code but it did not work, the current logged in user is still the post author instead of the assigned anonymous user.

  • Participant
    Level: Guru
    Posts: 900

    will be expecting your feed back sir.

    thanks

  • Participant
    Level: Guru
    Posts: 900

    1. No I dont want to limit the scope, this update should be applicable to all forms

    2. Yes i’m referring to post category (category id = 1487) while use ID that will inherit the submitted post = 4766806

    Thanks

  • Participant
    Level: Guru
    Posts: 900

    Kind reminder sir

    Thanks

  • Participant
    Level: Guru
    Posts: 900

    I want new users to be friends with all the featured members.

  • Participant
    Level: Guru
    Posts: 900

    I already tested the code but it did not work

  • Participant
    Level: Guru
    Posts: 900

    Hello Brajesh,

    Please any update thanks a lot

  • Participant
    Level: Guru
    Posts: 900

    Gentle reminder sir

    Thanks

  • Participant
    Level: Guru
    Posts: 900

    Ohh! cool

    thanks Brajesh