سؤال

I'm wondering if there's a way to add/edit/delete Taxonomy terms in a Rule with Drupal 7? I haven't found any way to do that.

Usecase: I'm trying to use Rules to maintain a (taxonomy) vocabulary of usernames of a certain role, so when a user's role is updated I add/remove their username.

هل كانت مفيدة؟

المحلول

This is how I would go about it:

In Rules UI:

1) In the events section I would select the option "After updating an existing user account".

2) In the condition section I would select the role which is updated.

3) In the Actions section I would write my own php code as I there is no option to change the users name there.

My php code:

As per rules you need to use the function hook_rules_action_info(). I would put this in a file mymodulename.rules.inc to reduce load.

/*
* Implementation of the hook_rules_action_info() 
* 
*/
function customvishal_rules_action_info()
{
 // Here You can check the db for the uid and change the username as what you want. 
 using the SELECT and INSERT commands. Let me know if this works for you or if you
 need further help.

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top