I have figured out how to get a few extra questions to my users when they register, but no way to use that information to automatically assign a role. My goal is to have users register, and then make extra features automatically appear if they have answered certain questions a certain way (in this case a pull down menu) by automatically assigning them a role and then using features on the privacy_node_bypass module. If I could get help with this, it would help me a lot!

Thanks, Caveman

Comments

jasonwhat’s picture

http://drupal.org/node/14308 should do it. Not sure about 4.6 compatiblity though.

caveman’s picture

I'd rather have the information accessible instantly, and the documentation seems to suggest the opt-in module uses cron to process. Not sure it will work for this

After working on the actual implementation a bit, I think I may have asked the wrong question. Using roles would work if they are assigned instantly everytime a user enters/modifies my custom profile question, but it seems easier to access their profile questions directly using php. Will post that question on a separate thread. If anyone has an idea how to "instantly" auto-assign roles, I'll keep following this thread as well.

Thanks!
Caveman

PS. I'm using 4.5

nevets’s picture

Could make a module that maps profile_field values to roles at the time of edit.
It would only need to implement hook_user(), something like

<?php
function profile2role_user($op, $edit, $user, $category)
{
	if ( $op == 'insert' || $op == 'update' )
	{
	         // The old value of the field
		drupal_set_message($user->profile_fieldname);
		// The new value od the field
		drupal_set_message($edit['profile_fieldname']);
	}
}
?>

Both the old and new value of the field are available and can be used on what action you want to take.

A more general solution that does not hardcode the profile field name would also want to have a page for setting up which field to act on and how to map it to roles.