BuddyDev

Search

[Resolved] Need to Limit Categories Users Can Post To in BuddyBlog

Tagged: 

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #157

    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 🙂

  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #159

    Awesome!

    I think by ID ascending would be the best for now.

    • This reply was modified 9 years, 4 months ago by Devin Stone.
    • This reply was modified 9 years, 4 months ago by Devin Stone.
  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #162

    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: 24697
    Brajesh Singh on #176

    Hi Devin,
    Just checking if you had time to look at my last reply. I am looking forward to hear from you.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #177

    Hey Brajesh,

    Sorry for the late reply, I just got back into the office today.

    It works perfectly! That should be everything I need! Thank you very much for your help. A+ support all around!

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #178

    Thank you Devin.
    No problem with the delay. Appreciate your positive feedback 🙂

    Closing this topic as resolved now.

The topic ‘ [Resolved] Need to Limit Categories Users Can Post To in BuddyBlog’ is closed to new replies.

This topic is: resolved