Posted by Aaron Stanush on May 1, 2009 at 4:35pm
| Project: | Organic groups |
| Version: | 6.x-1.3 |
| Component: | og.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
When a user is creating a new group, under "Membership requests" there is the option to choose whether the group is open, moderated, invite-only, or closed.
Is there a way to disable this choice for users? For example, if I am creating an open-community website, I would want every new group created to be open. Or at least, low-level roles would never see this option and the group would be open by default.
Comments
#1
you can achieve this using hook_form_alter on the node form and change the radio field to a value field with you wanted default value.
#2
I really need this, cause the approval method for a requester user is too confusing....
how can I use hook_form_alter?
#3
Use of hook_form_alter is done through the creation of your own "helper module" if I may use that terminology. Your module will be only waiting for a specific situation to occur. For instance, your module can waiting for a form do display in node/add or node/edit mode and than you can set some default values and maybe even turn the value into a hidden form value or disable the field after setting the desired default value.
Follow this link for more information about hook_form_alter:
http://api.drupal.org/api/function/hook_form_alter/6
#4
+1
Should not have to have a custom module for such basic functionality. Often we want to behavior to be consistent throughout a site without giving group creators a choice.
#5
create module and puts this code
function custom_forms_form_alter(&$form, &$form_state, $form_id) {if($form_id =='group_node_form'){
$form["og_selective"]["#type"] = 'hidden';
}
}
#6
What's your suggestion then servantleader?
#7
I think there should be a setting for default membership requests under: admin/og/og_access
There's a setting for all the other default parameters, it seems odd to miss this one.
I'll try writing a patch, not sure if it will need to patch og or og_access
#8
Patch attached - adds options to admin/og/og to show or hide the og_selective field on node forms and an option to set the default for og_selective.
Haven't tested too thoroughly - probably needs checking with og_access options.
#9
Changing the status to needs review
Also note the patch is against CVS branch 6--2
#10
Thnx!
#11
That patch, og-450842.patch, worked for me!
#12
Correction. I can confirm that the patch works for user 1, the "admin" user.
When creating a new group, the og_selective field no longer shows up for the admin user, but still shows up for all other users.
So it is not quite working right. I need og_selective to be hidden for all users, not just the admin user.
#13
Think I accidentally got the logic backwards
if (!user_access('administer nodes')) {$visibility = OG_MEMBERSHIP_VISIBLE_TRUE;
}
Should have been:
if (user_access('administer nodes')) {$visibility = OG_MEMBERSHIP_VISIBLE_TRUE;
}
The idea was to hide the option from most user, but show them to admin. OG already often relies on 'administer nodes' permission, so I've reused that.
Updated patch applied
#14
It seems that an alternative solution to this patch is using http://drupal.org/project/og_defaults
#15
Thank You jmseigneur for sharing the info. It worked for me !
#16
I prefer to see a multiselect form where OG's membership mode defaults for non-admins can be selected. Default all are enabled.
The #access element on group node form should be set to empty($options) || user_access('administer organic groups').