Help with some code that autp moves a topic when it has a reply

Extensions, styles and support for everything else about phpBB
Post Reply
Gary
Donor
Posts: 16
Joined: 24 Sep 2018, 22:28

Help with some code that autp moves a topic when it has a reply

#1

Post by Gary » 20 May 2020, 20:27

I'm using some code added to posting.php file with phpBB 3.2 to move topics from an RRS Feed forum to another forum if they get a reply. I added the code before this line.

Code: Select all

// Lock/Unlock Topic
This code works in doing the job I want, and yes, I know you shouldn't hack files adding code (but it works and there is no mod out there for doing it)

But what I've noticed is this, after the topic is auto moved from one forum to another. The forum it was moved from (shows the last posters name - as last poster) even though the topic is no longer on that forum. And the forum is was auto moved onto, that forum tends to show the topic starter as last reply (and not the name of the last poster to that topic)

After the topic is moved to another form (auto) as well. Notice the forum it was moved from is showing the post counter as higher than topic counter. So the post counter is still counting the reply on that forum it was moved from (even though that topic is no longer on that forum and was moved to another forum)

I would prefer when the topic get a reply and is auto moved to another forum. That the forum is was moved from doesn't not show a last reply to that topic (in forum last reply stats), and the forum it gets moved onto shows the name of the last poster and not the topic starter.

So wondering if anyone here can improve this code to use for moving a topic from one forum to another - when the topic gets a reply.

Code: Select all

            // Begin custom code
            $fid = 44;
            $to_fid = 23;

            if (($mode === 'reply' || $mode === 'quote') && $forum_id == $fid && $to_fid && !$post_data['topic_replies_real'])
            {
                include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
                move_topics($topic_id, $to_fid, true);
                $forum_id = (int) $fid;
            }
            // End custom code

User avatar
kasimi
mChat developer
Posts: 1056
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Help with some code that autp moves a topic when it has a reply

#2

Post by kasimi » 21 May 2020, 21:53

It might be that your code executes too early, and the core code that's executed after your edits overwrites whatever your code changed. Try moving it before these lines, around 1537:

Code: Select all

// Handle delete mode...
if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent'))

Gary
Donor
Posts: 16
Joined: 24 Sep 2018, 22:28

Re: Help with some code that autp moves a topic when it has a reply

#3

Post by Gary » 21 May 2020, 22:43

Thanks. That seems to work perfect now in all regards.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests