PDA

View Full Version : [solved] update forum counters on hook newpost_process


omardealo
10-20-2014, 12:59 PM
hello ,

i Create plugin on hook : newpost_process
it job move threads to another forumid when user posted duplicate thread Content.

if(//Condition)
{
$dataman->set('forumid', $vbulletin->options['search_duplicate_thread_forumid']);
}

every thing is okay , but now i needed to update forum counters .
I tried a lot :

// update counters
require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters($vbulletin->options['search_duplicate_thread_forumid']);
build_forum_counters($foruminfo['forumid']);
build_forum_counters($forum['forumid']);

In the end I think it does not work except in the hook : newpost_complete
after threads greated already .

is anyway to make update to forum counters on hook : newpost_process
Or another way to update the forum counters when this condition is true !

kh99
10-20-2014, 01:06 PM
I think maybe it only works in newpost_complete because when newpost_process is called, the new post has not been saved yet. Maybe you can do something like, in newpost_process:

if(//Condition)
{
$dataman->set('forumid', $vbulletin->options['search_duplicate_thread_forumid']);
$update_counters = 1;
}
else
$update_counters = 0;



then in newpost_complete,

if ($update_counters)
{
// forum counter build code here
}

omardealo
10-20-2014, 01:27 PM
I think maybe it only works in newpost_complete because when newpost_process is called, the new post has not been saved yet. Maybe you can do something like, in newpost_process:

if(//Condition)
{
$dataman->set('forumid', $vbulletin->options['search_duplicate_thread_forumid']);
$update_counters = 1;
}
else
$update_counters = 0;



then in newpost_complete,

if ($update_counters)
{
// forum counter build code here
}

yeah that's What I understood it in the end, after many trying .
Your idea completely succeeded
Thank you to my brother :up: