Get 15% off on all our plugins, themes and memberships till 4th December. Use coupon: BLACKFRIDAY2021.

BuddyDev

Search

Doubled Published Article and Custom Code not working

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41231

    Hi,
    I am using BuddyBoss Platform and Theme.

    In the “Published” Tab there is both “You haven’t posted anything yet.” and “You haven’t published anything yet.”
    Also when I publish an article it is published two times.
    I tried to use the code for limiting the number of characters in both Title and Description, but it is not working with BuddyBlog Pro.
    However with BuddyBlog was working fine.

    add_filter('bsfep_validate_post','buddyblog_custom_validate_title_content',10,2);
    
    function buddyblog_custom_validate_title_content($is_error,$post_data){
    //if there is already an error, let us return
    if($is_error)
    return $is_error;
    
    //otherwise, let us check for the length of the title/contet
    $min_title_length=50;//assuming 50 characters
    $min_content_length=200;//assuming 200 charactes, will include space
    
    $title = trim($post_data['bp_simple_post_title']);
    $content = trim($post_data['bp_simple_post_text']);
    
    //get the form
    $form_id = $post_data['bp_simple_post_form_id'];
    
    $form = bp_get_simple_blog_post_form_by_id($form_id);
    
    if(strlen($title)<$min_title_length){
    
    $form->message=sprintf('Sorry, The title is too short. The title must be atleast %d characters long.',$min_title_length);
    $is_error=true;
    return $is_error;
    }
    
    if(strlen($content)<$min_content_length){
    $form->message=sprintf('Sorry, The content is too short. The post content must be atleast %d characters long.',$min_content_length);
    $is_error=true;
    return $is_error;
    
    }
    
    return $is_error;
    } 

    Could you please give support for this matters
    Thank you

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41235

    Hi,

    Also I uploaded the Featured Image but not saved with the article.
    I tried to edit the article but there was no image in the uploaded images.
    I tried to upload it again but i got the same result.
    The image is not uploaded nor saved.

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 19762
    Brajesh Singh on #41237

    Hi Niculae,
    I am sorry for the inconvenience.

    1. For the featured Image issue, Please visit Dashboard->BuddyBlog->Settings->[Your post type] and make your that you have “Editing” enabled for all members. That will fix it. It will not be needed in future versions(Already fixed in the next release coming tomorrow but it is required for current version due to a permission issue).

    2. The code base for BuddyBolg and BuddyBlog Pro are different. The above code will not work for BuddyBlog Pro. I will share the snippet a bit late today.

    3. Double publishing and message:- Can you please tell me which theme are you using? Are you using it with BuddyPress or BuddyBoss?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41243

    Hi,
    I am using BuddyBoss Theme
    Thank you

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41244

    Hi,

    I deleted the page created with the shortcode [bbl-create-by-post-type post_type = ‘post’] and now I only have the From created in BuddyBlog.
    Now it looks like I can upload and save the images.
    Please let me know if this is the correct setting.

    Thanks

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41245

    Does the module has a feature such as words counter for Title and Content?
    It might be helpful in the editor so users can know how many words is still required for publishing the article.
    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 19762
    Brajesh Singh on #41246

    Hi Niculae,,
    Thank you for the replies.

    1. You can use the shortcode on a page or the create tab on profile. It is your preference and we support both of these. Using shortcode allows you to have a larger screen for posting, using create tab provides better integration as other tabs are available on the same screen.

    Both will work fine. Please feel free to use any of those.

    Please note: If you use shortcode, Please make sure to select the page on the BuddyBlog Pro Post Types “Create” section. Otherwise, it will not work.

    2. Thank you for the suggestion about the title and the content word count. We are hoping to enable word count for content in next 2 updates. I am not sure about enabling this for the title.

    Please feel free to use javascript to do that for title.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41247

    Hi,

    OK, I am looking forward to the title and the content word count.

    When will you will share the snippet for the Title and Content Length?

    How can I use BuddyBoss image uploader instead of WordPress media uploader?

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 19762
    Brajesh Singh on #41250

    Hi,
    Here is a code sample showing validations.

    
    
    /**
     * BuddyBlog Pro field validation rule.
     */
    add_filter( 'bblpro_validation_errors', function ( $errors, $submitted_data, $post_data ) {
    
    	$status = $post_data['post_status'];
    
    	if ( ! empty( $submitted_data['bbl_post_title'] ) && bblpro_custom_get_words_count( $submitted_data['bbl_post_title'] ) > 20 ) {
    		$errors->add( 'bbl_post_title', __( 'Title must have less than 20 words.' ) );
    	}
    
    	// additional check for publish.
    	if ( 'publish' === $status && bblpro_custom_get_words_count( $submitted_data['bbl_post_content'] ) < 150 ) {
    		$errors->add( 'bbl_post_content', __( 'Content must have at least 150 words.' ) );
    	}
    
    	return $errors;
    }, 10, 3 );
    
    /**
     * Counts number of words in a string.
     *
     * @param string $str string.
     *
     * @return int
     */
    function bblpro_custom_get_words_count( $str ) {
    	$words = preg_split( "/[\n\r\t ]+/", $str, - 1, PREG_SPLIT_NO_EMPTY );
    
    	return count( $words );
    
    }
    

    Please feel free to extend it.

    No, the plugin can not use BuddyBoss uploader currently.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 43
    Niculae Constantinescu on #41254

    Hi,

    Thanks for the code.

    Still The articles are published twice, how can I solve this issue.

    I hope that in the next version you will include these features, or if needed I can pay for this modification:
    1 – Use of BuddyBoss image uploader instead of WordPress media uploader
    2 – When deleting an article the Featured Image to be deleted also.
    3 – The title and the content word count.

    Meanwhile please tell me how can I fix this Duble Posting of Articles.

    In the “Published” Tab there still are both

    “You haven’t posted anything yet. Add New”
    and
    “You haven’t published anything yet. Add New”

    Thank you for your support.

You must be logged in to reply to this topic.

This topic is: not resolved