vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   newpost_process hook (https://vborg.vbsupport.ru/showthread.php?t=288546)

Twilkey 10-02-2012 04:23 AM

newpost_process hook
 
I need to know how to get the threadid in this hook. I am adding a tag to the database during this hook, and the only data I can't seem to get is the threadid. I have looked at the function_newpost.php file and from what I see in there $threadinfo['threadid'] should work. I have even tried $threadinfo[threadid] but that did not work either.

PHP Code:

              $vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "tag
            (tagid,tagtext,dateline)
            VALUES ('','"
.$fieldvalue."','".TIMENOW."')");
            
            
$last_id mysql_insert_id();
            
              
$vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "tagthread
            (tagid,threadid,userid,dateline)
            VALUES ('"
.$last_id."','".$threadinfo['threadid']."','".$vbulletin->userinfo['userid']."','".TIMENOW."')"); 


kh99 10-02-2012 10:21 AM

I think the problem is that when you're creating a new thread, the threadid hasn't been created yet. It won't be known until the thread is actually saved. It looks like at hook newpost_complete you would be able to use the threadid.

Also, do you want your code to run for both threads and posts? If you only want it to run when a new thread is created, you'll want to check for $type == 'thread'.


All times are GMT. The time now is 01:15 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.01064 seconds
  • Memory Usage 1,720KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete