Assign Role Based On content_profile Field Selection

I'm trying to do this with d6.
just wondering how using content_profile helps assign a role conditionally, based on information entered in the profile fields?
for example:
if user choose university A from dropdown list ---> his role selected as A university student
if user choose university B from dropdown list ---> his role selected as B university student

thanks

Comments

TechNikh’s picture

I am looking for this feature too. did you find any solution?

TommyK’s picture

I am also looking for something like this. Any updates?

Taxoman’s picture

Version: 6.x-2.0-beta1 » 7.x-1.x-dev
Component: Documentation » Code
Category: support » feature
hefox’s picture

This issue is specifically d6, why was it moved to d7? content profile isn't for d7 last I heard.

If can create a module, which can be rather simple, don't really need auto assign role, just a simple module that does hook_nodeapi $op == 'insert' || $op == 'update', and save the user account with new role based on cck field.

armin1980’s picture

Version: 7.x-1.x-dev » 6.x-2.0-beta1
Priority: Normal » Major

Desperately need it! Tried almost everything, to my knowledge it needs a new module

dalvir’s picture

@hefox thnx
i did this to work for my website in d6, i used content profile module for profile field
in my own module for website, handle hook_nodeapi
$node->field_utype[0]['value'] is my cck field for user role (single choice only, for multiple use foreach)

function mymodule_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {

  global $user;
  if ($op == 'insert') {
	  if($node->type == "profile"){
		 $uid = $node->uid;
		 $account = user_load(array('uid' => $uid));
    	 $myroles = $account->roles;
    	 $rolenames = user_roles(TRUE);
		 $rid = $node->field_utype[0]['value'];
    	 $myroles[$rid] = $rolenames[$rid];
    	 user_save($account, array('roles' => $myroles));
		 drupal_set_message(t('Saved !title.', array('!title' => $rid)));
	  }
  }
}