BuddyDev

Search

[Resolved] Buddyblog – allow user to select only one category when posting

  • Participant
    Level: Initiated
    Posts: 1
    Isabel on #23537

    Hi there,

    I have tried a few plugins and searched this forum for an answer but no luck. The plugins I tried only work on the wp-admin backend and I needed this to work when end-user posts a new post from their buddypress profile.

    How can I make the user select only one category when posting? Buttons are currently of type checklist – it would be great if these could be converted to radio or ideally to select with dropdown (I have quite a few categories).

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

    Hello Isabel,

    Thank you for posting. Yes, it can be done easily. Please try the following code in your active theme “functions.php” file. It will change checkbox categories to drowndown category.

    
    /**
     * BuddyBlog Categories as dropdown
     *
     * @param array $settings Settings.
     *
     * @return array
     */
    function buddydev_buddyblog_categories_as_dropdown( $settings ) {
    
    	if ( empty( $settings['tax'] ) ) {
    		return $settings;
    	}
    
    	foreach ( $settings['tax'] as $taxonomy => $detail ) {
    		$settings['tax'][$taxonomy]['view_type'] = 'dd';
    	}
    
    	return $settings;
    }
    
    add_filter( 'buddyblog_post_form_settings', 'buddydev_buddyblog_categories_as_dropdown' );
    
    

    Please let me know if that works or not.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 1
    Isabel on #23567

    Worked beautifully!!!! Thanks so much!!!

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

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Buddyblog – allow user to select only one category when posting’ is closed to new replies.

This topic is: resolved