BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Devin,

    1. to set a default category when the user does not choose it

    
    
    add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
    function buddydev_add_default_category_to_post( $post_id ) {
        
    	$tax = array_filter( $_POST['tax_input'] );
    	
    	if( empty( $tax ) && $post_id ) {
    		//no category was set
    		$term = 32;//ID
    		wp_set_object_terms( $post_id, $term, 'category' );
    		
    	}
        
    
    }
    
    

    Change the value of term with the ID of the category you want to assign.

    2. To Order the list display, I am sorry but that will need another update for simple front end post. you can download it from the site now. and then, as in my previous replies, I had posted the code for modifying setting, here is updated version of that

    
    function buddyblog_show_custom_cats( $settings ) {
    	$tax = array();
    	 
    	$tax['category'] = array(
    
    		'taxonomy'		=> 'category',
    		'view_type'		=> 'dd',
    		'child_of'		=> 29, //CHAGE It with the correct ID,
    		'orderby'		=> 'slug',
    		'order'			=> 'ASC'
    	);
    	
    	$settings['tax'] = $tax;
    	
    	return $settings;
    }
    
    

    Hope that helps.

    Please do let me know how it went for you.

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Anders,
    I am sorry but I won’t be able to have the second option included in today’s upgrade. To make that efficient, It will need time to implement.

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Devin,
    Thank you.
    I am glad that it did work 🙂

    1. That is doable, we will need to use some code to do that

    2. Yes, it is doable too. We are using wp_dropdown_categories() which allows us to sort by ID,Name,slug in ascending or descending order. which order you want?

    Please let me know and I will put the code 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Anders,
    Thank you. I will have this option today 🙂

    About the 2nd option, That depends on the size of the community. If there are 1000 users, It is not too much but if there are 100,000 users, then It will take a lot of time as we will have to check the preference for individual users if it is set or not and then update.

    If we plan to implement it in future, It will be all about time as PHP scripts have time limit, the update will be like doing it in batches. So, It is not going to consume all resources but take a lot of time for the larger community.

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Michel,
    Welcome to BuddyDev Forums.

    I just looked at the pdf an I see you just want to shorten the displayed activity content.

    At the moment, SWA uses normal BuddyPress ‘bp_activity_content_body’ method and we can filter on

    
    
    bp_get_activity_content_body
    
    

    The problem with this approach is we are not sure if the output is being generated by the BuddyPress or the SWA.

    I think, SWA needs an update to cleanup the code too, so please allow me upto 8-12 hours and I will have this available as an option in the widget itself.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Hans,
    Can you please open a new topic with enhancement. Let us leave this topic for Delyth.

    I have added some enhancement 2-3 days ago to the plugin and will be happy to continue doing that 🙂

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Anders,
    Welcome to BuddyDev forum.

    Thank you for asking this. There is a catch and that’s why We haven’t implemented it. If we implement it in simple ways, Admins may reset the preference for the existing users(who already updated).

    Is that ok? We want to go with all or nothing approach to use simple sql update. If we start checking for user preference and then updating, It will be a very resource consuming operations.

    If the all or nothing approach is fine, please let me know and we will have it implemented.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Devin,
    1. Please upgrade to simple front end post plugin version 1.2.2

    2. Please put the following code in your bp-custom.php

    
    
    add_filter( 'buddyblog_post_form_settings', 'buddyblog_show_custom_cats', 100 );
    
    function buddyblog_show_custom_cats( $settings ) {
    	$tax = array();
    	 
    	$tax['category'] = array(
    
    		'taxonomy'		=> 'category',
    		'view_type'		=> 'dd',
    		'child_of'		=> 29 //CHAGE It with the correct ID
    	);
    	
    	$settings['tax'] = $tax;
    	
    	return $settings;
    }
    

    Change the vale of child_of with the actual ID of your “User Blog” category.

    That will show the dropdown list on Post Create/edit. will work for any level deep.

    Now, to show the category parents, Please make sure you copy wp-content/plugins/buddyblog/template/buddyblog folder to your theme. So, now you have yourtheme/buddyblog folder where three files are there. These files are used to display the BuddyBlog post etc on user profile.

    Now, check for the file/code that generates link to category. In that file, you will see code like this

    
    get_the_category_list( ', '  )
    

    Please change that to

    
    get_the_category_list( ', ','single' ) )
    

    After that, try posting and see if it works. Please do let me know how it went for you.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    And to achieve what I said in my last post will be as simple as changing

    
    get_the_category_list( ', ')
    
    

    to

    
    get_the_category_list( ', ','single' )
    

    in our post listing template

  • Keymaster
    (BuddyDev Team)
    Posts: 24446

    Hi Devin,
    I have got the first case working. I had to modify the simple front end post plugin slight to accommodate child_of argument for taxonomy.

    I have a question about your last requirement. Why not we just assign the child selected category only to the post and while listing, we list from that child to the top level.

    A post in any child category of a category will also appear in the archive of the parent category of the selected category, so that is never a problem.