Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2009, 10:06 PM
renlok renlok is offline
 
Join Date: Mar 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default code to post a thread

im building a mod and one of the features i need is for it to automatically make threads but i cant seem to get it to work this the code ive got atm ive taken it from the newthread.php file but it doesnt work or give me any information as to why.

PHP Code:
$result $db->query_read_slave(
        
"SELECT * FROM " TABLE_PREFIX "mods WHERE id = " intval($_REQUEST['id']));

    
$mod $db->fetch_array($result);

    
// set arrays
    
$foruminfo = array();
    
$newpost = array();
    
$errors = array();
    require_once(
DIR '/includes/functions_newpost.php');
    
//...
    
$foruminfo['forumid'] = 2;
    
$newpost['message'] = '[url=http://localhost:8888/forum/mods.php?do=view&id=' $mod['id'] . ']Link to mod[/url]
    ' 
$mod['description'];
    
$newpost['title'] = $mod['title'];
    
$newpost['username'] = $mod['username'];
    
$newpost['poststarttime'] = time();
    
$newpost['rating'] = 0;
    
// trick it
    
$tmp_id $vbulletin->userinfo['userid'];
    
$vbulletin->userinfo['userid'] = $mod['userid'];
    
build_new_post('thread'$foruminfo, array(), array(), $newpost$errors);
    
$vbulletin->userinfo['userid'] = $tmp_id;
    
print_r($errors); 
anyone got any ideas?
Reply With Quote
  #2  
Old 12-13-2009, 01:50 AM
renlok renlok is offline
 
Join Date: Mar 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok it sort of works now . now atleast something happens but it returns
Quote:
That username is already in use or does not meet the administrator's standards. If you are racken and you have forgotten your password, click here.
in the error parameter which doesnt make any sense surly that would be a registration error?
Reply With Quote
  #3  
Old 12-13-2009, 03:04 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know exactly what you are trying to do, but I am guessing the problem lies where you are reassigning the userid. That is the area I would be looking into.

And what does this mean - "If you are racken and" - racken?
Reply With Quote
  #4  
Old 12-13-2009, 11:18 AM
renlok renlok is offline
 
Join Date: Mar 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

because the thread im trying to create i want to be posted under a different user so that user can edit it so if i run that script logged into an account renlok i was trying to make a thread posted by racken
Reply With Quote
  #5  
Old 12-13-2009, 02:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I understand that. What I'm saying is that it seems to me that that is the area that has problems so that is the area I would focus on. Try posting the thread without switching the userid - does it work then? How about manually putting in a userid - like '5' (use a valid userid) - does it work then? Typical debug stuff to do.
Reply With Quote
  #6  
Old 12-14-2009, 12:14 PM
renlok renlok is offline
 
Join Date: Mar 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

finally got it to work
thanks
Reply With Quote
  #7  
Old 12-14-2009, 12:23 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you want a new thread or a new post? It looks to me like you are using a new post method for a new thread.

You should be using the datamanager built in to vbulletin to post threads.

My suggestion would be to go and download my Welcome Thread mod and look how I did it.
https://vborg.vbsupport.ru/showthread.php?t=229473
Reply With Quote
  #8  
Old 12-14-2009, 01:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by renlok View Post
finally got it to work
thanks
Out of curiosity, what was the problem?
Reply With Quote
  #9  
Old 12-14-2009, 04:21 PM
renlok renlok is offline
 
Join Date: Mar 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it was trying to set the userid as 0 so it was trying to make the post as a guest which was why i was getting that error message. but it works now apart from it times out after making the post which is annoying but i dont mind.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:29 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04899 seconds
  • Memory Usage 2,249KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete