It would be nice to have the ability to limit which roles a user can select from when using the 'User Create' content from context admin. I've created a patch for this feature. I will attach it in the comments below.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Brown’s picture

Status: Active » Needs review
FileSize
4.99 KB

Attached Patch

Steven Brown’s picture

Because I've switch the 'Alter Roles' form element from a Checkbox to Radios, I've added a third option to the radios called 'Disallow' which will not allow the user to edit the roles that can be given.

I only did this because there isn't a way to reset the radio button on the form so in case someone wanted to go back to the default with out creating it from scratch.

cdracars’s picture

Applied the patch twice...

checking patch plugins/context_admin/user_create_menu.inc...
warning: plugins/context_admin/user_create_menu.inc has type 100755, expected 100644
Applied patch plugins/context_admin/user_create_menu.inc cleanly.

Received this message both times however it seems the patch did work as expected, radio buttons worked fine. Not sure about the warnings though... maybe just me :)

Steven Brown’s picture

Not sure why you are getting the warning. I git cloned the 7.x-1.x branch and applied the patch.

Checking patch plugins/context_admin/user_create_menu.inc...
Applied patch plugins/context_admin/user_create_menu.inc cleanly.

I didn't get the type issue. Not sure what that issue is OR if it is an issue.

Steven Brown’s picture

FileSize
112.88 KB

Alter Roles Context Admin

realityloop’s picture

Status: Needs review » Reviewed & tested by the community

applied to stable without issue, works as advertised.

EclipseGc’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/plugins/context_admin/user_create_menu.incundefined
@@ -32,16 +33,30 @@ function context_admin_user_create_menu_content_form($form, $form_state) {
+  $form['context_admin_user_roles_limited'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Limited Roles'),
+    '#description' => t('Select the roles to show when using this form.'),
+    '#options' => $options,
+    '#default_value' => is_array($default_limited) ? $default_limited : array($default_limited),

If we can't get states working on this, can we get ctools dependent? We don't need to be showing this if they're not selecting limited.

In general I really like what you're attempting to do here, let's get this working and see how it goes from there.

Eclipse

Steven Brown’s picture

Status: Needs work » Needs review
FileSize
5.07 KB

Alright I tried using FAPI #states and it wouldn't work for me in the page manager page but it would for a FAPI form... So as suggested by EclipseGc I've used Ctools dependency option instead.

Steven Brown’s picture

Added the interdiff between the two patches. Thanks EclipseGc for that tidbit :)

EclipseGc’s picture

Status: Needs review » Fixed

committed to 7.x-1.x, I'll tag a release shortly for 1.2.

Eclipse

EclipseGc’s picture

Status: Fixed » Patch (to be ported)

We should probably try to backport this to D6.

EclipseGc’s picture

Version: 7.x-1.x-dev » 6.x-1.0-beta14