Topic: redirecting to home page only in certain forums?

is it possible at all that when a reply is made, instead of punbb redirecting you to the forum/topic, it redirects you to a requested url instead?

i only want this to happen from maximum of 2 forums though

2 (edited by pogenwurst 2006-08-29 19:39)

Re: redirecting to home page only in certain forums?

In post.php, try finding this:

        if (!$pun_user['is_guest'])
        {
            $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
            $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
        }

        redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);

And replacing it with this:

        if (!$pun_user['is_guest'])
        {
            $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
            $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
        }

        redirect('INSERT URL OF YOUR CHOICE HERE', $lang_post['Post redirect']);

EDIT: Just remembered you only want it in two forums. You'll have to add an if statement to check the forum ID. I have to go now, but if you need anymore help just ask.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: redirecting to home page only in certain forums?

yeah, i figure i can just add if statements to the forum ids to get this working

hit me when i was in the bath before, ill let you know how i get on anyway mate

cheers

Re: redirecting to home page only in certain forums?

having a bit of trouble with the IF statement mate

added this at the top of the page

$results = mysql_query("SELECT * FROM forums") or die(mysql_error());
    while ($fblogid = mysql_fetch_array($results));


then replaced the existing redirect with this:

// If the posting user is logged in, increment his/her post count
        if (!$pun_user['is_guest'])
        {
            $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
            $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
        }
        if($fblogid['id'] == "1")
        {
        redirect('/', $lang_post['Post redirect']);
        }
        else
        {
        redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
        }
    }


no joy so far though

Re: redirecting to home page only in certain forums?

$results = mysql_query("SELECT * FROM forums") or die(mysql_error());
    while ($fblogid = mysql_fetch_array($results));

Wouldn't that output multiple rows?

What are you trying to determine? The forum id?

Looking for a certain modification for your forum? Please take a look here before posting.

Re: redirecting to home page only in certain forums?

yes mate, the forum id that the reply will be in

Re: redirecting to home page only in certain forums?

There's no need for an extra query, just use $fid.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: redirecting to home page only in certain forums?

if($fid == '1')
        {
        redirect('/', $lang_post['Post redirect']);
        }
        else
        {
        redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
        }


not working

Re: redirecting to home page only in certain forums?

Oh, and remove the quotes. It's a number, not a string.

Looking for a certain modification for your forum? Please take a look here before posting.

10

Re: redirecting to home page only in certain forums?

mate, ive tried it every which way, and it doesnt seem to want to work

at my wits end on this one

Re: redirecting to home page only in certain forums?

Because $fid only applies for new topics.
To make it work for new posts and new topics, using $cur_posting['id'] instead

12

Re: redirecting to home page only in certain forums?

smarty

tried that also, its just redirecting every reply regardless of forum to the new URL

Re: redirecting to home page only in certain forums?

So this:

                // If the posting user is logged in, increment his/her post count
                if (!$pun_user['is_guest'])
                {
                        $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
                        $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
                }

                redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);

Is now this:

                // If the posting user is logged in, increment his/her post count
                if (!$pun_user['is_guest'])
                {
                        $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
                        $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
                }

                if($fid == '1')
                {
                                redirect('', $lang_post['Post redirect']);
                }
                else
                {
                                redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
                }

And it still doesn't work? :-/

There is one change in my code above, and that's changing the destination URL to '' as opposed to '/' (because '' becomes index.php)

14

Re: redirecting to home page only in certain forums?

i had the '/' in, as i want it to redirect back to the home page of the site, which happens

ive now changed the code back to the following:

// If the posting user is logged in, increment his/her post count
        if (!$pun_user['is_guest'])
        {
            $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
            $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
        }
        if($cur_posting['id'] = 1)
        {
        redirect('/', $lang_post['Post redirect']);
        }
        else
        {
        redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
        }

that redirects every reply, no matter what forum it is posted in, back to the homepage of the site

Re: redirecting to home page only in certain forums?

Yes, because you used =, the assignment operator, as opposed to ==, the comparison operator

16

Re: redirecting to home page only in certain forums?

ahhhhh

your a star mate

TYVM

hopefully once ive done this site for a mate, i can throw a few tutorials up on integrating it with a front end

Re: redirecting to home page only in certain forums?

Smartys wrote:

Because $fid only applies for new topics.
To make it work for new posts and new topics, using $cur_posting['id'] instead

Aaargh, I looked for something like that, but couldn't find it. sad

Looking for a certain modification for your forum? Please take a look here before posting.