Extending Drupal Commons with Feature Alter Hooks
Drupal Commons provides a great framework for building community-driven sites. With topic (organic) groups at its core, Commons uses several content types to help grow communities such as
- wikis to promote collaboration among users
- polls for users to vote on
- events for users to organize meet-ups and functions
- Are only accessible by a custom "Event Manager" role
- Require an additional field for the event's host
function mymodule_user_default_permissions_alter(&$permissions) {
$permissions['create event content'] = array(
'name' => 'create event content',
'roles' => array(
'0' => 'Event Manager',
),
);
}
This alters the existing permissions set by Commons to use our event manager role. To add the host field, it's business as usual using the simple point-and-click interface of the Features UI. Export the feature and add the previously mentioned code snippet. We've just extended Commons without hacking or rebuilding a contributed module.

Add new comment