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
for drupal 7:
global $user; // Retrieve user object for currently logged in user.
$role_name = 'test role'; // Name of role to add
// Get RID of role
$rid = db_query("SELECT r.rid FROM {role} r WHERE r.name = :rname", array(':rname' => $role_name))->fetchField();
// Save the user object with the new role.
if (!isset($user->roles[$rid])) {
$roles = $user->roles + array($rid => $role_name);
user_save($user, array('roles' => $roles));
}
thanks rix.