• Hello!

    I have a problem with my first plugin, because I don’t know, how the category_save_pre filter works.

    The plugin should automatically select the category, if there is only one category. I know, there’s a setting for default_category, but I use another plugin, which exclude for certain users the default_category.

    function chooseCategory($id)
    {
    	$cat = get_categories(array('hide_empty'=>FALSE));
    	if (count($cat) == 1)
    	{
    		$id = $cat[0]->cat_ID;
    	}
    	return $id;
    }
    add_filter('category_save_pre', 'chooseCategory');

    What kind of parameters do I get for chooseCategory and what should be returned by this function?

    Thanks
    crille

  • The topic ‘category_save_pre’ is closed to new replies.