get the vid of last saved vocabulary How can I get the last saved vid. taxonomy_vocabulary_save($vocabulary); is not returning the vid.
I have used the following way.

$vocabulary = new stdClass();
$vocabulary-&gt;name = 'Currencies';
$vocabulary-&gt;machine_name = 'currencies';
taxonomy_vocabulary_save($vocabulary);
// get the vid of currency
$vocabulary = taxonomy_vocabulary_machine_name_load('currencies');
//save a variable for vid
variable_set('currencies_vid', $vocabulary-&gt;vid);   


Is there any better method?
The vocabulary object that you pass to taxonomy_vocabulary_save() will automatically be populated with the new vid, so you don't need to reload the vocabulary after you've saved it.

This code will work fine:

$vocabulary = new stdClass();
$vocabulary-&gt;name = 'Currencies';
$vocabulary-&gt;machine_name = 'currencies';
taxonomy_vocabulary_save($vocabulary);

variable_set('currencies_vid', $vocabulary-&gt;vid);