Skip to main content
deleted 31 characters in body
Source Link
MRC
  • 139
  • 10

I have this scenario that I am trying to walk through. I am new to creating custom modules, but I'm working on it (only way to learn...right?)

How would I go about doing this as I'm currently getting an error when trying. I have a role: 'venue admin' that will be responsible for adding other users with the role of 'customer'. I already am using the module: Role Delegation to handle the permissions side of things. But on the User Registration screen, I would like the customer role to be pre-selected and hidden from display.

This is what I have so far:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mandatory_role_form_user_register_form_alter(&$form, &$form_state,   &$form_id) { 
global $user;

if(in_array('venue admin', $user->roles)) {   
// by default notify user of new account is checked  
    $form['account']['notify']['#default_value'] = TRUE;
// the only role the venue admin role can create is a customer so this is checked and hidden.
    $form['account']['roles']['#options']['#access']$form['account']['roles']['#access'] = FALSE;
  }
}

obviously, this is not complete and missing the ability to set the role as well as hide it. Any suggestions?

I have this scenario that I am trying to walk through. I am new to creating custom modules, but I'm working on it (only way to learn...right?)

How would I go about doing this as I'm currently getting an error when trying. I have a role: 'venue admin' that will be responsible for adding other users with the role of 'customer'. I already am using the module: Role Delegation to handle the permissions side of things. But on the User Registration screen, I would like the customer role to be pre-selected and hidden from display.

This is what I have so far:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mandatory_role_form_user_register_form_alter(&$form, &$form_state,   &$form_id) { 
global $user;

if(in_array('venue admin', $user->roles)) {   
// by default notify user of new account is checked  
    $form['account']['notify']['#default_value'] = TRUE;
// the only role the venue admin role can create is a customer so this is checked and hidden.
    $form['account']['roles']['#options']['#access'] = FALSE;
  }
}

obviously, this is not complete and missing the ability to set the role as well as hide it. Any suggestions?

I have this scenario that I am trying to walk through. I am new to creating custom modules, but I'm working on it (only way to learn...right?)

How would I go about doing this as I'm currently getting an error when trying. I have a role: 'venue admin' that will be responsible for adding other users with the role of 'customer'. I already am using the module: Role Delegation to handle the permissions side of things. But on the User Registration screen, I would like the customer role to be pre-selected and hidden from display.

This is what I have so far:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mandatory_role_form_user_register_form_alter(&$form, &$form_state,   &$form_id) { 
global $user;

if(in_array('venue admin', $user->roles)) {   
// by default notify user of new account is checked  
    $form['account']['notify']['#default_value'] = TRUE;
// the only role the venue admin role can create is a customer so this is checked and hidden.
    $form['account']['roles']['#access'] = FALSE;
  }
}

obviously, this is not complete and missing the ability to set the role. Any suggestions?

Source Link
MRC
  • 139
  • 10

Pre-select a role on user register form and hide from display?

I have this scenario that I am trying to walk through. I am new to creating custom modules, but I'm working on it (only way to learn...right?)

How would I go about doing this as I'm currently getting an error when trying. I have a role: 'venue admin' that will be responsible for adding other users with the role of 'customer'. I already am using the module: Role Delegation to handle the permissions side of things. But on the User Registration screen, I would like the customer role to be pre-selected and hidden from display.

This is what I have so far:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mandatory_role_form_user_register_form_alter(&$form, &$form_state,   &$form_id) { 
global $user;

if(in_array('venue admin', $user->roles)) {   
// by default notify user of new account is checked  
    $form['account']['notify']['#default_value'] = TRUE;
// the only role the venue admin role can create is a customer so this is checked and hidden.
    $form['account']['roles']['#options']['#access'] = FALSE;
  }
}

obviously, this is not complete and missing the ability to set the role as well as hide it. Any suggestions?