drupal 7 – hook_user_insert not fired rules

The operation should be as follows: trigger an event after registering a new user:

  • test_rules_rules_event_info (example_rule_event) it’s my event
  • test_rules_user_insert when a user is registered
  • test_rules_customFunction the function that is called by the rule

when a user is registered -> my event is triggered -> the test_rules_customFunction function is called by running the php code set by the rules interface

if I create the user from the drupal interface, this is done.
while if I create it through custom code, the event is not triggered

I wrote this code:

function test_rules_rules_event_info() {
  return array(
    'example_rule_event' => array(
      'label' => t('Regola test, quando un utente รจ registrato'),
      'module' => 'test_rules',
      'group' => 'test' ,
      'variables' => array(
        'current_user' => array('type' => 'user', 'label' => t('The current user.')),
function test_rules_user_insert(&$edit, $account, $category) {
  watchdog("test_rules_user_insert", '<pre>' . print_r( $account, true) . '</pre>');
  rules_invoke_event('example_rule_event', $account);
function test_rules_customFunction($current_user){
  watchdog("test_rules_customFunction", '<pre>' . print_r( $current_user, true) . '</pre>');