BuddyDev

Search

[Resolved] BUDDYBLOG Issues

  • Participant
    Level: Master
    Posts: 497
    Daniel on #14022

    Hi,

    As the BuddyBlog plugin only make sense to my website if I can change the following, I would like to ask if my requirements will be possible:

    1. When a user does edit the blog, then the blog is posted with the NEW DATE OF TODAY, but I would like when the user edits the post that the post-date remains the same as its INITIAL POSTE DATE.

    2. The same thing when unpublishing post and re-publishing, then the post changes the date again and takes the date of today but I would like that the system does not change the post date, MEANS WHEN REPUBLISHING I WANT THAT THE POST DATE IS THE SAME AS ITS INITIAL POST DATE.

    3. When the user edits his post and republishes it, or unpublish and republish, then the system does automatically change the category of the post and APPLIES THE DEFAULT CATEGORY which is set under WordPress settings->writing in WordPress backend. I WANT THAT THE CATEGORY REMAINS THE SAME AND DOES NOT CHANGE.

    4. I would like to hide the WORDPRESS default category FOR THE USER which is set under WordPress settings->writing in WP backend.

    5. I want to enable the user to change category when editing his post or when writing his post but that he can choose only one category AND NOT MULTIPLE CATEGORIES.

    Could you please tell me what I need to do in order to make these explained 5 issues working ? Do you think it will be possible to adjust all these explained features in BuddyBlog plugin ?

    Thank you for your feedback.

    Kind regards,
    Daniel

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #14029

    Hi Daniel,
    Thank you for posting.

    I had asked @ravisharma to look into it after your email message. He will be posting back here and assisting you with it.

    The 1,2 are bug and will be fixed in plugin. For the others, He should be posting the code.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 497
    Daniel on #14035

    Hi Brajesh,

    Many thanks for your info, much appreshiated!

    Looking forward to it 🙂

    Thank you.

    Best regards,
    Daniel

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #14066

    Hello Daniel,

    I have updated the plugin. please download the latest version of “BP Simple Frontend Post” plugin. you can download from the following url

    https://buddydev.com/plugins/bp-simple-front-end-post/

    and use the following code to prevent user to select only one category.

    
    function buddydev_validate_form( $error, $post ) {
    
    	if ( ! function_exists( 'buddyblog_get_option' ) || ! buddyblog_get_option( 'enable_taxonomy' ) ) {
    		return $error;
    	}
    
    	$error_message = '';
    	$term_count = ( isset( $post['tax_input'] ) ) ? count( $post['tax_input']['category'] ) : 0; // I'm assuming you are refering only post category.
    
    	if ( empty( $term_count ) ) {
    		$error_message = __( 'Please select one category' );
    	} elseif ( $term_count > 1 ) {
    		$error_message = __( 'Please select only one category' );
    	}
    
    	if ( ! empty( $error_message ) ) {
    		return array(
    			'error'   => true,
    			'message' => $error_message,
    		);
    	}
    
    	return $error;
    }
    add_filter( 'bsfep_validate_post', 'buddydev_validate_form', 10 , 2 );
    
    

    let me know if it works or not

    Thank You
    Ravi

  • Participant
    Level: Master
    Posts: 497
    Daniel on #14067

    Hi Ravi,

    Many thanks for your information.

    I have updated the plugin and I have checked if it worked and indeed, point 1. 2. and 3. are resolved. That’s excellent, thank you!

    Now just one question about the additional code you have provided: do I need to implement the code inside the bp-custom.php file under /wp-content/plugins/bp-custom.php and then just insert the code at the end of the file on a new line ?

    Thank you for clarification.

    Kind regards,
    Daniel

  • Participant
    Level: Master
    Posts: 497
    Daniel on #14094

    Hi Ravi,

    Please disregard my answer #14067 as I have found out how to implement the code and to use it.

    The code you have provided works with Success!

    I only have one more question.

    I would like to hide some categories in the category list to choose.

    The category slug I want to hide is called “blog”.

    Could you please help me and tell me which code I need to add in order that it does not show the Category “blog” ?

    Thank you very much!

    Kind regards,
    Daniel

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #14099

    Hello Daniel,

    Just use the following code to show only selected categories on post new form.

    
    function buddydev_include_categories( $settings ) {
    
        if ( ! isset( $settings['tax'] ) || ! isset( $settings['tax']['category'] ) ) {
            return $settings;
        }
    
    	$settings['tax']['category']['include'] = array( 77, 75 ); // Replace with comma separated list of categories ids you want to include.
    
        return $settings;
    }
    
    add_filter( 'buddyblog_post_form_settings', 'buddydev_include_categories' );
    

    and let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 497
    Daniel on #14101

    Hi Ravi,

    Thanks for your code, I have implemented it with Success and it works.

    The only thing is, as I am a PHP beginner I do not understand how I can find out my other Category ids as 77, 75, …

    Could you please tell me precisely how I can find out the Category ids or is there a way to use the slugs ?

    Many thanks for your help!

    Kind regards,
    Daniel

    • This reply was modified 6 years, 8 months ago by Daniel.
  • Participant
    Level: Master
    Posts: 497
    Daniel on #14104

    Hi Ravi,

    Please disregard my ticket #14101. I have found out the IDs of all my Categories and I have implemented them with success.

    Thank you very much!

    By the way, this will be my last concern:

    On my website, the FEATURED IMAGE is a REQUIRED FIELD and in BuddyBlog Backend Settings I can choose if I would like to enable the user to upload images when editing.

    Is there a code you could provide to make the FEATURED IMAGE a required field in order if the user deletes the featured image when editing, he will get an alert message that the featured image is mandatory, like “PLEASE SELECT A FEATURED IMAGE!”

    Many thanks for your help!

    Kind regards,
    Daniel

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #14112

    Hello Daniel,

    Good to know that you have found categories ids by your own. For validating featured image replace the previous code for validating categories with the following code.

    
    function buddydev_validate_form( $error, $post ) {
    
    	if ( ! function_exists( 'buddyblog_get_option' ) ) {
    		return $error;
    	}
    
    	$error_message = '';
    
    	if ( buddyblog_get_option( 'enable_taxonomy' ) ) {
    		$term_count = ( isset( $post['tax_input'] ) ) ? count( $post['tax_input']['category'] ) : 0; // I'm assuming you are refering only post category.
    
    		if ( empty( $term_count ) ) {
    			$error_message = __( 'Please select one category' );
    		} elseif ( $term_count > 1 ) {
    			$error_message = __( 'Please select only one category' );
    		}
    
    		if ( ! empty( $error_message ) ) {
    			return array(
    				'error'   => true,
    				'message' => $error_message,
    			);
    		}
    	}
    
    	if ( $post['_thumbnail_id'] == -1 ) {
    	    return array(
    	        'error' => true,
                'message' => __( 'Featured image is required' ),
            );
        }
    
    	return $error;
    }
    add_filter( 'bsfep_validate_post', 'buddydev_validate_form', 10 , 2 );
    

    And let me know if works or not.

    Thank you
    Ravi

The topic ‘ [Resolved] BUDDYBLOG Issues’ is closed to new replies.

This topic is: resolved