I've been trying in vain to do this for a while... the code I have is -

<?php
function cr_paypal_promote_user() {
  global $user;
  if ($user->uid > 0) {
    $roles = $user->roles;
    if(!isset($roles[8])) {
      $roles[8] = 'Team Member';
    }
    if(!isset($roles[16])) {
      $roles[16] = 'authenticated user + trusted';
    }
    user_save($user, array('roles' => $roles));
  }
}
?>

When I run it, I get error messages like 'Can't connect to the database' and the username is incorrect.

What am I doing wrong?

Pete.

Comments

j_ten_man’s picture

Sounds like you have some issues with your settings.php file. Where are you trying to run this code from? Is it in the standard course of a Drupal page? Are you able to view other pages on your Drupal site?

pbarnett’s picture

It's part of the code in a form_submit; after further investigation, I'm fairly sure that this code is OK - though I've added a cache_clear_all($user->uid .':', 'cache_menu', TRUE);
as per the workflow_ng equivalent since.

The code was working at one point; I'm begining to think that eaccelerator is the true source of my grief.

Just wanted to check that I'm not doing anything stupid in this snippet...

Pete.

duckzland’s picture

I think the snipplet is good

--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com

pbarnett’s picture

The word is snippet, not snipplet.

You're not even trying to help - you're just advertising your website.

Pete.