How to assign role with PHP in Drupal?

前端 未结 4 2070
误落风尘
误落风尘 2021-02-06 16:38

I need to assign a kind of \"premium status\" to members that purchase an amount equal or greater than 100 € via PHP.

Conditional Actions are already set up (user = anon

4条回答
  •  北海茫月
    2021-02-06 17:14

    Just though I'd update the snippet for Drupal 7. Otherwise it works fine :)

    $rid = db_query("SELECT r.rid FROM {role} r WHERE r.name = :rname", 
                    array(':rname' => $role_name))->fetchField();
    

提交回复
热议问题