vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Additional Re-Direct Option (https://vborg.vbsupport.ru/showthread.php?t=253630)

Arrogant-One 11-13-2010 07:38 PM

Additional Re-Direct Option
 
Firstly, let me say I made an honest and lengthy attempt to do this myself before bothering my fellow vB owners.

The Goal

I have a vB forum catering to chess players. Obviously tournaments are played and announced regularly, although the Calendar feature gets ignored big time.

What I would like to have is, when a member posts a new thread about their upcoming chess tournament, an option like the Post a Poll Option.

As everyone is aware the poll option firstly posts the members post as post #1 of the new thread, and then it re-directs them to the create your poll page.

I'm after pretty much the same thing, except once they have posted their first post in the new thread, I want them redirected to the Ranged Calendar entry page -

http://www.ozchess.com.au/calendar.php?do=add&c=1

As the Additional Options are often ignored, I was hoping this could be a button alongside the Submit New Thread and Preview Post buttons when someone is posting a new thread. Maybe the button could be called New Thread + Calendar Entry.

Is there anyone who could please tell me how I can achieve this?

kh99 11-13-2010 08:23 PM

In template newthread you can add your button like this: find the existing buttons by searching for submit_new_thread and add
Code:

<input type="submit" class="button" name="calendar" value="New Thread + Calendar Entry" accesskey="c" tabindex="1" />
(you can make a phrase for it if you want)


Then add a plugin to get the value if that button is pushed: hook location newthread_post_start, code:
PHP Code:

$newthread['calendar'] = $vbulletin->input->clean_gpc('p''calendar'TYPE_STR); 


One more plugin to redirect to the calendar, hook location newthread_post_complete, code:
PHP Code:

if ($newthread['calendar'])
{
    
$vbulletin->url 'calendar.php?' $vbulletin->session->vars['sessionurl'] . "do=add&c=1";
    if (
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads'])
    {
        eval(
print_standard_redirect('redirect_postthanks'truetrue));
    }
    else
    {
        eval(
print_standard_redirect('redirect_postthanks_nopermission'truetrue));
    }


If you want you might want to make another phrase that says "Thanks for posting, now you're going to the calendar" or something like that (although I find you don't often really see that page anyway). BTW, I don't know if you really need the check for permissions here, but I just copied the code for submitting a poll).

The only thing about this is that after filling in the calendar entry it won't take you back to your thread, but maybe that's OK (or maybe you can work that part out).

Arrogant-One 11-14-2010 05:54 AM

Thank you dude! :)

You are a legend. Thanks again.

Arrogant-One 11-26-2010 07:10 AM

The above didn't work unfortunately :(

kh99 11-26-2010 08:49 AM

Well, I did test it before posting, but it's possible that your setup is different somehow, or maybe I misunderstood what you wanted. Does it not work at all, or what does it do?

kh99 11-28-2010 10:44 PM

1 Attachment(s)
I made the above changes into the attached product file you can import, and I also added phrases.

Shanj 11-29-2010 01:56 PM

kh9 this looks like good work I think it's the kind of thing quite a few will want.

What I need is to make all new posts in a selected forum redirect to a certain URL once they have posted.
Not as a user option, as 100% always.
I need to put it on several forums but it is always the same URL destination.

Is that possible?

kh99 11-29-2010 02:40 PM

Yes, you could just copy the code that's under the hook location into a plugin so you can change it. In other words, make a new plugin using hook location newthread_post_complete with this code:

PHP Code:

if ($newpost['postpoll']) // user selected poll
{
    
$vbulletin->url 'poll.php?' $vbulletin->session->vars['sessionurl'] . "t=$newpost[threadid]&polloptions=$newpost[polloptions]";
    if (
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads'])
    {
        eval(
print_standard_redirect('redirect_postthanks'truetrue));
    }
    else
    {
        eval(
print_standard_redirect('redirect_postthanks_nopermission'truetrue));
    }
}
else if (
$newpost['visible']) // normal submit
{
    if (
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads'])
    {
                                
// user has permission to see thread (this is probably the "normal" case)
        
$vbulletin->url 'showthread.php?' $vbulletin->session->vars['sessionurl'] . "p=$newpost[postid]#post$newpost[postid]";
        eval(
print_standard_redirect('redirect_postthanks'));
    }
    else
    {
                                
// user can't see thread
        
$vbulletin->url 'forumdisplay.php?' $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
        eval(
print_standard_redirect('redirect_postthanks_nopermission'truetrue));
    }
}
else
{
                
// Thread waiting for moderation
    
$vbulletin->url 'forumdisplay.php?' $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
    eval(
print_standard_redirect('redirect_postthanks_moderate'truetrue));


Then change the "$vbulletin->url =" lines as needed. You probably don't want to change the redirect to poll.php, so if the user is adding a poll you'd have to do something more complicated to get it to redirect after adding the poll. But you could change the other 3 $vbulletin->url lines to get it to redirect somewhere else, for instance:

Code:

$vbulletin->url = "http://www.foo.com";
I hope that makes sense. I guess it would be nice to have acp options to set the url, but this will work.

Shanj 11-29-2010 04:33 PM

kr9 I get the outline but I'll need to ask you more questions. Hope that's OK.
Right now I don't see how to make this apply to a selected forum only.

kh99 11-29-2010 04:56 PM

Oh..sorry, I missed that part. you could do something like this:

PHP Code:

if (in_array($foruminfo['forumid'], array(123))) // list your forum ids in place of 1, 2, 3...
    
$redirect_url "http://www.foo.com"// url to redirect to

if ($newpost['postpoll']) // user selected poll 

    
$vbulletin->url 'poll.php?' $vbulletin->session->vars['sessionurl'] . "t=$newpost[threadid]&polloptions=$newpost[polloptions]"
    if (
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']) 
    { 
        eval(
print_standard_redirect('redirect_postthanks'truetrue)); 
    } 
    else 
    { 
        eval(
print_standard_redirect('redirect_postthanks_nopermission'truetrue)); 
    } 

else if (
$newpost['visible']) // normal submit 

    if (
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']) 
    { 
         
// user has permission to see thread (this is probably the "normal" case) 
         
if (!empty($redirect_url))
            
$vbulletin->url $redirect_url;
         else
            
$vbulletin->url 'showthread.php?' $vbulletin->session->vars['sessionurl'] . "p=$newpost[postid]#post$newpost[postid]"
        eval(
print_standard_redirect('redirect_postthanks')); 
    } 
    else 
    { 
          
// user can't see thread 
         
if (!empty($redirect_url))
            
$vbulletin->url $redirect_url;
         else
            
$vbulletin->url 'forumdisplay.php?' $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]"
        eval(
print_standard_redirect('redirect_postthanks_nopermission'truetrue)); 
    } 

else 

          
// Thread waiting for moderation 
         
if (!empty($redirect_url))
            
$vbulletin->url $redirect_url;
         else
            
$vbulletin->url 'forumdisplay.php?' $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]"
    eval(
print_standard_redirect('redirect_postthanks_moderate'truetrue)); 



If you wanted you could have different forums redirect to different URLs by adding "else if" to that first if statement.

--------------- Added [DATE]1291058521[/DATE] at [TIME]1291058521[/TIME] ---------------

Sorry, the above had a mistake that I (hopefully) fixed.


All times are GMT. The time now is 07:17 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01131 seconds
  • Memory Usage 1,792KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete