PDA

View Full Version : Redirect user back to the homepage after submitting post?


peolit
11-07-2008, 04:25 PM
Hi there...
I'm trying to make it so that when a user hits the 'post reply'or 'submit new thread' buttons, they wil automatically be redirected back the the forum index.

I hope that makes sense...can anyone help me?
Thanks

UKBusinessLive
11-07-2008, 05:15 PM
If it is a form you're using, you can use

<input type="hidden" name="redirect" value="http://www.yoursite.com">

When someone clicks on "Continue" or "Submit" button, it will redirect to the page you specify in the "value" key. You can also use php variables with this.

peolit
11-07-2008, 05:19 PM
Thanks for the advice!

I need it to submit the users post (just like when I hit 'submit reply' to post this reply) and then send the user back to the index page...

Will that work?

UKBusinessLive
11-07-2008, 05:29 PM
Should do, not sure which template you'll have to edit tho' , so perhaps one of the more advanced coders could shed some light on this.

Could end up being a useful hack ;)

peolit
11-07-2008, 05:38 PM
Thanks UK
Here is the button I am working with in the newreply template:

<input type="submit" class="button" name="sbutton" id="{$editorid}_save" value="$vbphrase[submit_reply]" accesskey="s" tabindex="1" />

Right now when a user hits it to post a reply, they get the $vbphrase"postthanks_moderate" in a splash screen and then the user is automatically redirected back to the thread.

I need them redirected back to the index instead of the thread after they submit thier post, and I can't seem to figure this out :confused:

noppid
11-07-2008, 05:53 PM
Let's talk newreply, you figure out newpost.

on hook newreply_post_complete

set $vbulletin->url to the url of the index.

execute...
eval(print_standard_redirect('redirect_postthanks' , true, true));

peolit
11-07-2008, 06:17 PM
This looks awesome, noppid, but I can't get it to work- probably because I'm not typing in the right place. Sorry.

Where exactly do I put all that in?
thanks for the help.

noppid
11-07-2008, 06:21 PM
I didn't test it, but that is where I would start...

Hook:

$vbulletin->url = 'index.php?' . $vbulletin->session->vars['sessionurl'];
eval(print_standard_redirect('redirect_postthanks' , true, true));

peolit
11-07-2008, 06:37 PM
I'm in the newreply template- is that where I should be typing or do I need to be elsewhere? I added that code after the submit button code, like this:

<input type="submit" class="button" name="sbutton" id="{$editorid}_save" value="$vbphrase[submit_reply]" accesskey="s" tabindex="1" />


$vbulletin->url = 'index.php?' . $vbulletin->session->vars['sessionurl'];
eval(print_standard_redirect('redirect_postthanks' , true, true));

and it didn't do anything differently...

Thanks for your patience with my inexperience!

noppid
11-07-2008, 06:53 PM
Let's talk newreply, you figure out newpost.

on hook newreply_post_complete

set $vbulletin->url to the url of the index.

execute...
eval(print_standard_redirect('redirect_postthanks' , true, true));

You need to add it to a new plug in on hook newreply_post_complete, not into a template.

peolit
11-07-2008, 07:07 PM
It Works!!

Thankyou very much, noppid- you saved the day!

noppid
11-07-2008, 07:15 PM
Cool deal, now do you understand how to apply it to newthread?

Oh hell, use hook newthread_post_complete with the same code and try.

EDIT:

Opps, you gotta deal with polls. You need something like..


if(!$newpost['postpoll'])
{
$vbulletin->url = 'index.php?' . $vbulletin->session->vars['sessionurl'];
eval(print_standard_redirect('redirect_postthanks' , true, true));
}


When posting a poll, they may go back to the thread. I didn't look that far ahead.

If you moderate you may need if(!$newpost['postpoll'] && $newpost['visible'])

Same over on newpost.

peolit
11-07-2008, 07:19 PM
Aleady done. Thanks alot.

noppid
11-07-2008, 07:34 PM
Cool deal. Glad to see someone learn something and apply it. Good luck.