XF 2.1 Create redirect thread programmatically

GPA-R

Active member
Hi,

I use a script to create threads externally. Works fine. I want however whenever I create a new thread to have another thread created which will be a redirect of the first.

a) Create thread in forum A
b) Create a thread in forum B which will be redirecting to the thread in forum A

I thought of using the functionality of thread "move" to simulate this.

I am up to a point where I create the thread in forum A, I create a redirect using:
PHP:
$redirectRepo = $app->repository('XF:ThreadRedirect');
$redirectRepo->createThreadRedirectionDouble($firstForum, $destinationForum, 0);

But there is no thread created in Forum B. In xf_thread_redirect table however I can see that a redirect has been correctly/successfully created. (and when testing it it manually works)

Edit: Nevermind, I used the thread mover service and works fine. It has the same outcome without the hustle of reversing its process.

@mods You may want to delete the topic.
 
Last edited:
Top Bottom