Question: how is it possible that using wp\_insert\_category throw a fatal error ?

I am using it as explained : <http://codex.wordpress.org/Function_Reference/wp_insert_category>
with no change except: 

```
$cat_defaults = array(
    'cat_name' => 'some_name',
    'category_description' => 'as asdfasdf sdf adfa fas f',
    'category_nicename' => '',
    'category_parent' => '',
    'taxonomy' => 'category'
 );
$someSome = wp_insert_category($cat_defaults);

```

i dont know if its relevant however i execute it on `add_action( 'init', array($this, 'registerCustoms') );`

And i get the following error :

`Fatal error: Call to undefined function wp_insert_category() in /home1/stodeckc/public_html/podio-wp-sync/wp-content/plugins/podio_management/libs/appSync/appSync_custom.php on line 61`

Any ideas?

Answer: 
The `init` action is the wrong place. This is because `init` runs on all requests, admin or front-end, but the `wp_insert_category` function is an admin-side only function. You generally don't insert categories from the front end.

Move to a more specific action, one that will be run in the admin side. Probably from your plugin's admin pages.
I think here is not required to admin\_init, because this also define on taxonomy.php

So please use on this way:

```
require_once('wp-load.php' );
require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');

$cat_defaults = array(
    'cat_name' => 'some_name',
    'category_description' => 'as asdfasdf sdf adfa fas f',
    'category_nicename' => '',
    'category_parent' => '',
    'taxonomy' => 'category'
 );
$someSome = wp_insert_category($cat_defaults);

```