Looking at the og_node_create_links function and particularly the discussion / changes that were implemented with this Issue: #1848028: The $destination paramater for the og_node_create_links function is not used this function still seems to behave incorrectly in that it is always setting a destination value on the link regardless if one is passed. Is there a reason for this that I may be missing? I understand the need in some implementations to have a user create a piece of content and be redirected to the groups home page, but why is this the default behavior?

Ideally, the function would not set a destination unless one was passed, and if the dev wanted the create links in a way that redirected the end user back to the group home page, then they could pass the url in as destination. But as it stands, you can't unset the destination in this function.

This came up when we tried to use the function and have the user redirected to the content they just created (default node create behavior).

Basically, just drop the else block in the code below. (And then fix og_extras if that module wants the default behavior to be "Go back to home page") I'm happy to submit a patch to change this, but I just wanted to make sure there wasn't a reason for it.

Around line 3307 of og.module

 $options  = array(
    'query' => array($field_name => $gid),

  if ($destination) {
    $options['query']['destination'] = $destination;
  else {
    $options['query'] += drupal_get_destination();


#6 og-1983450-6.patch817 bytesCottser
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es). View
#6 interdiff.txt416 bytesCottser
#1 og-1983450-1.patch818 bytesCottser
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


Cottser’s picture

Status: Active » Needs review
818 bytes
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es). View

I ran into this same problem myself.

Here is a proposed solution that would maintain API backwards compatibility. Pass FALSE as the destination parameter to not append a destination to the node create links.

Status: Needs review » Needs work

The last submitted patch, og-1983450-1.patch, failed testing.

Cottser’s picture

Version: 7.x-2.2 » 7.x-2.x-dev

Correcting version number.

Cottser’s picture

Status: Needs work » Needs review

#1: og-1983450-1.patch queued for re-testing.

itamar’s picture

+++ b/og.moduleundefined
@@ -3371,7 +3371,7 @@ function og_node_create_links($group_type, $gid, $field_name, $destination = NUL
+  else if ($destination !== FALSE) {

Minor: else if => elseif

Cottser’s picture

416 bytes
817 bytes
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es). View

Thanks @itamar, old habits…

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.