Assign user to a role programmatically

Categories:

<?php
function _assign_user_role($order, $account) // This assigns the user to "Consumer" role.
{
	$usr = user_load($order->uid);
	$details = array(
		'uid' => $order->uid,
		'roles' => array(
			6 => 'Consumer' // 6 is the role ID, may need to update this on going live
			)
		);
	user_save($usr, $details);
}
?>