Is there any way to keep the user on the page that they submit the form block from instead of taking them to the node that was just created?

I would like it to just remain on the current page, acknowledge somehow that the node was created and then reset the form.

Comments

mikey_p’s picture

I think this could be an option set for each block. I'll look into it

Bilmar’s picture

+1 subscribing

nedjo’s picture

Possible approaches in a patch might be:

a. in form_alter, set $form['#redirect'] = $_GET['q'];

or

b. In form_alter, register a #submit callback. In the callback, set $_REQUEST['destination'] = $_GET['q'];

robby.smith’s picture

+1 subscribing

mikey_p’s picture

Title: Remain on current page » Choose redirect page after form submission
Assigned: Unassigned » mikey_p
Category: support » feature

Also closing #418790: Registration Destination in favor of this issue.

YK85’s picture

subscribing

rules action for redirect might be helpful to reference

To: [                     ] ? [                  ] # [                   ]

[x] Force redirecting to the given path, even if a destination parameter is given
Per default drupal doesn't redirect to the given path, if a destination parameter is set. Instead it redirects to the given destination parameter. Most times, the destination parameter is set by appending it to the URL, e.g. http://example.com/user/login?destination=node/2

[ ] Immediately issue the page redirect
Use this with caution! If checked, the path redirect is issued immediately, so the normal execution flow is interrupted.
Steff Vanhaverbeke’s picture

+1 subscribing

doublejosh’s picture

StatusFileSize
new1.65 KB

Here is a patch that adds an admin page to form block with a checkboxes to select redirect on registration.

Please double check this work for your scenarios and doesn't conflict with other login modules. (I'm using Logintobaggin with immediate login selected.)

Additionally, it would be better to place this checkbox control on the registration block settings form at admin/build/block/configure/formblock/user_register rather than the one I've just created at admin/settings/formblock, but I don't know how to deal with adding options to that form. Any help? Course it's not a requirement, just an improvement.

PS: I did a check_plain on the $form['#redirect'] = $_GET['q']; for security reasons. Let me know if something else is required as well.

doublejosh’s picture

Status: Active » Needs review
doublejosh’s picture

StatusFileSize
new1.65 KB

Whops. Sorry. Ran the patch backwards. Redo...

doublejosh’s picture

StatusFileSize
new1.67 KB

Also found that I needed to test and not remove the redirect when registering from the normal /user/register page!

doublejosh’s picture

My patch adds this feature, any help on getting it to the block admin instead of a form block settings page that doesn't need to exist?

YK85’s picture

I was wondering if there has been any further development in this feature.
It would be nice to be able to specify the redirect for each form block.
Thank you

doublejosh’s picture

My patch just adds "Redirect user back to originating page on register."

Are you thinking a path field on the block edit page?

YK85’s picture

Hello,

Ah yes, I was thinking a path with tokens to 'originating page' , etc.
I guess this would be a different feature request.

doublejosh’s picture

I guess the question I was asking is whether Token would be necessary.
Options of "originating page" OR a hard coded URL seems like it would cover it.

Since the only other form blocks I know of (besides registration) is node/add/thing and webform neither of those could make much use of a Token after submit.
Unless of course you want to go to a page using the UID perhaps? But then you could accomplish this with grabbing the UID from the global user (if it was a view for example.)
I just can't think of a real need to Token... plus I'm not experienced enough to build it :)

Just trying to get some clear use cases before I add any of this to my patch.

- - - - - -

Also, I believe I found a bug when the signup-able node is "closed" the registration checkbox still shows, as goes the registration block... since it's visibility is dependent on that. It causes an error when signup tries to register the person for the event. So we'll just need to check for "open" status.

Anyone willing to test this bug with my patch?

I personally use Context to show my blocks, so there might be a need for a Context Signup Status plugin. But that's another thread.

mikefyfer’s picture

This functionality would be great. I could just accomplish this with a hook_form_alter, but I'd prefer to use the patch's method.

Any idea if this patch is going to get rolled into the next release?

doublejosh’s picture

No clue. I worked that up a while ago and never heard anything back.

Anonymous’s picture

I accomplished this using rules. Pretty simple

quinns’s picture

Yeah, rules is a good way to do this redirect-after-posting.

doublejosh’s picture

Agreed :)
I'm a Rules lover now too.

mikey_p’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

I haven't seen any recent interest in this issue, so I'm closing it since it's filed against 6.x which is now unsupported.