I've put in a new hook here so that the $group_options that are added to the ucreate_user_form can be adjusted by other modules.

diff --git a/html/sites/all/modules/ucreate/ucreate_og.module b/html/sites/all/modules/ucreate/ucreate_og.module
index 0677458..a613635 100644
--- a/html/sites/all/modules/ucreate/ucreate_og.module
+++ b/html/sites/all/modules/ucreate/ucreate_og.module
@@ -118,6 +118,12 @@ function _ucreate_og_form(&$form) {
   else if ($og) {
     $group_options = array($og);
   }
+  
+  // allow other modules to alter the group options
+  foreach(module_implements('ucreate_og_form_alter') as $module) {
+    $function = $module .'_ucreate_og_form_alter';
+    call_user_func_array($function, $group_options);
+  }
 
   $options = array();
   foreach ($group_options as $group) {

This allows me to check a certain user role that can add a user to any group, not just the ones they are joined into.

Comments

sirkitree’s picture

I'll add that ideally, there should be a permission that would just allow a role to do this, but this serves my purposes for now. Happy to write it up the other way if you prefer.

sirkitree’s picture

Status: Active » Needs review

Marking as needs review.

sirkitree’s picture

Oops, small bug: changed call_user_func_array to call_user_func

diff --git a/html/sites/all/modules/ucreate/ucreate_og.module b/html/sites/all/modules/ucreate/ucreate_og.module
index 0677458..a613635 100644
--- a/html/sites/all/modules/ucreate/ucreate_og.module
+++ b/html/sites/all/modules/ucreate/ucreate_og.module
@@ -118,6 +118,12 @@ function _ucreate_og_form(&$form) {
   else if ($og) {
     $group_options = array($og);
   }
+  
+  // allow other modules to alter the group options
+  foreach(module_implements('ucreate_og_form_alter') as $module) {
+    $function = $module .'_ucreate_og_form_alter';
+    call_user_func($function, $group_options);
+  }

   $options = array();
   foreach ($group_options as $group) {
sirkitree’s picture

Ok, for real this time ;)

diff --git a/html/sites/all/modules/ucreate/ucreate_og.module b/html/sites/all/modules/ucreate/ucreate_og.module
index 0677458..4c8e521 100644
--- a/html/sites/all/modules/ucreate/ucreate_og.module
+++ b/html/sites/all/modules/ucreate/ucreate_og.module
@@ -119,6 +119,12 @@ function _ucreate_og_form(&$form) {
     $group_options = array($og);
   }
 
+  // allow other modules to alter the group options
+  foreach(module_implements('ucreate_og_form_alter') as $module) {
+    $function = $module .'_ucreate_og_form_alter';
+    $group_options = call_user_func($function, $group_options);
+  }
+
   $options = array();
   foreach ($group_options as $group) {
     $group = (object) $group;

alex_b’s picture

Why don't you use just form_alter() for this?

sirkitree’s picture

the ucreate stuff is already form altered in, and when i tried to do so in my own module, the og info was not available.

jmiccolis’s picture

Status: Needs review » Postponed (maintainer needs more info)

@sirkitree is that just due to a module weight issue? If you set you modules weight to higher than ucreate it should just work right?

sirkitree’s picture

Hrm, I don't know. I think I remember that I tried that and it did not work. It's been long enough that I'm not working on the project I was when I had this issue, but it's coming up for Phase 2 soon. davexoxide is on that part though so I'll let him know about this ticket and maybe he will follow up.