Posted by Iulian Arcus on August 5, 2011 at 3:50pm
Hello everyone,
I'm trying to create a new action to generate a password. Seems easy, but I can't get it to work.
The action_info
$return['generate_random_password'] = array(
'group' => t('MyGroup'),
'label' => t('Generate password'),
'base' => 'rules_action_generate_password',
'provides' => array(
'generated_password' => array(
'type' => 'text',
'label' => t("Generated Password"),
),
),
); and the base function
function rules_action_generate_password() {
$return = array();
$return['generated_password']=user_password(10);
return $return;
}After a whole struggle I got it to show in my actions list, but after I select it I get an empty form with a continue button that goes round and round.
Comments
Associated array
To have your action returning values to Rules, you need to send back an associated array with all the new parameters – not just the single value (which would be problematic if you were to create two different parameters).
In your case, you need to return this:
return array('generated_password' => $return,
);
Two more notes:
baseparameter.There are some tutorials on writing Rules plugins available at http://nodeone.se/node/895 (and of course at http://drupal.org/node/878720).
Good luck!
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 150+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding.