Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In user_roles.action.inc, if the view doesn't include group_type and gid as the first and second arg, you get a unsupported operand error. It makes more sense to rely on og_context() to get the group_type and gid.
Change includes/user_roles.action.inc line 12:
// Get the group type and group ID from the Views arguments.
list($group_type, $gid) = $context['view']->args;
To:
// Get the group type and group ID from the group context.
$og_context = og_context();
$group_type = $og_context['group_type'];
$gid = $og_context['gid'];
Comments
Comment #1
amitaibuThis can be a fallback in case $context['view']->args doesn't have what we want. Patches are welcome.
Comment #2
weekbeforenextThe attached patch identifies the gid and group_type arguments, if they exist, and uses them first. If both arguments are not found, it uses og_context. However, when I called og_context(), it didn't work so I used $_SESSION['og_context'] instead.
Comment #3
amitaibuWrong indentation and trailing space.
Well, we need to figure out why og_context() didn't work, instead of hacking it ;)
Comment #4
weekbeforenextOkay, I think I fixed the spacing and indentation. Thanks for the tip!
I know it's a little hack, but I need to implement now so I want it to work until we can find a better fix :)
Comment #5
RoySegall CreditAttribution: RoySegall commentedI made a total fix the patch: First the we check that the og context module is exists, if so we get the og type and og ID from the context. If not, check that we have the og type and og ID from the $context['view']->args.
@weekbeforenex, you include in comment #4 the patch with the white spaces. You should check that in the future that you posted the correct patch.
Comment #6
amitaibuyou should
if (module_exists('og_context') && $og_context = og_context()) {
in one line, or you will get a notice.if => elseif
if it's empty, you can return here, no need for the same check below.
Comment #7
amitaibubtw, this change should apply to all VBO actions
Comment #8
RoySegall CreditAttribution: RoySegall commentedComment #9
RoySegall CreditAttribution: RoySegall commentedComment #10
amitaibuThis looks strange...
Comment #11
RoySegall CreditAttribution: RoySegall commentedComment #12
amitaibuFixed
else if
=>elseif
and committed, thanks.