Hi,
I wrote a module, that I called og_black_list, that allows group administrators to black list some users trying to register to an open group (in other words, you can say the group is open, but some users are denied access). Everything works fine, except that I'm using the 'og user insert' hook, which doesn't allow me full control over the user access.
Here is the code I'm using:
/**
* Implements hook_og
*/
function og_black_list_og($op, $gid, $uid, $args) {
if($op == 'user insert') {
// Make sure the user is allowed
if(!_og_black_list_user_allowed($gid, $uid)) {
// The user is not allowed to subscribe to this group, delete him
og_delete_subscription($gid, $uid);
drupal_set_message(t('You have been blocked by the administrator of this group and can not join it'), 'error');
}
}
}
There are two problems with this code: first, I have to actually let the user join, and then delete him immediately if he is not allowed. Would be better if I could simply forbid the user from joining. Second, the message 'You have been blocked by the administrator...' gets displayed, but right after this message follows a 'You are now a member of %group', sent by the og module.
What would be the best way for me to solve these two problems ?
Thank you.
Comments
Comment #1
amitaibuYou can implement hook_menu_alter() and change the access callback of
og/subscribe/%nodeto be your own function that checks if the user isn't black listed.Comment #2
guillaumev commentedHi,
Thanks !