Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2005, 01:22 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help finding proper location for new thread code in register.php...

I set my forum up to auto generate a thread for our new users after they confirm the email address. The code works, but not all the time. I'm guessing that I have it in the wrong area in the register.php script. Can someone here point me to where it should go?

I suck at PHP coding, so thanks for your help.

Here is the code I'm using:
PHP Code:
// ########## START THREAD CREATION ##########
            
$forumid $pmoptions['regforum'];
            
$foruminfo fetch_foruminfo($forumid);
            
$post[title] = $pmoptions['regpmtitle'];
            
$post[message] = $pmoptions['regpmtext'];
            
$post[poststarttime] = TIMENOW;
            
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
            
$post['emailupdate'] = 9999;
            
build_new_post('thread'$foruminfo, array(), 0$post$errors);
            
// ########## END THREAD CREATION ########## 
and I put it after this line in register.php:
PHP Code:
// delete activationid
        //$DB_site->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid=$userinfo[userid] AND type=0"); 
Reply With Quote
  #2  
Old 06-17-2005, 03:00 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What version of Vbulletin are you using?
Reply With Quote
  #3  
Old 06-17-2005, 05:23 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry. Good question. vB 3.0.3
Reply With Quote
  #4  
Old 06-17-2005, 06:30 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It looks like it's in the right spot. Can you be more specific about when it does or doesn't work? What's different in the users or situation when it fails?

Amy
Reply With Quote
  #5  
Old 06-17-2005, 06:36 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

most of the time, the thread is created. Sometimes it isn't. I can't see anything different about the user's profiles...

Thanks for your responses!!!
Reply With Quote
  #6  
Old 06-23-2005, 03:01 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I think I've figured part of it out. It doesn't seem that the code is grabbing the actual $bbuserinfo['userid']. Sometimes its null.

Any chance you could take a look at all the code for me? As it actually does a couple of things. Thanks.

(Sorry its kind of a mess, I cant really write my own code, so I've pieced together other peoples code to make this.)

This is my register.php (with an extra line of actual vB code on either end, so that you know where I stuck it)
PHP Code:
// delete activationid
        //$DB_site->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid=$userinfo[userid] AND type=0");

        // ###################################################################
        // # WELCOME HACK 
        // ###################################################################

        
$username $bbuserinfo['username'];
        
//$username = $_POST['username'];
        
        // Process each one of the replacement vars
        
$vars = array(
            
'$bbtitle' => $vboptions['bbtitle'], 
            
'$username' => $username
            
'$email' => $email
            
'$userid' => $userid
        
);
        
        
$pmoptions['regpmtext'] = $vboptions['regpmtext'];
        
$pmoptions['regpmtitle'] = $vboptions['regpmtitle'];
        
$pmoptions['regforum'] = $vboptions['regforum'];
        
        
// Now that we have the options, we need to process eaach of the 
        // vars we can use
        
foreach($vars AS $_key => $_value)
        {
            
$pmoptions['regpmtext'] = str_replace($_key$_value$pmoptions['regpmtext']);
            
$pmoptions['regpmtitle'] = str_replace($_key$_value$pmoptions['regpmtitle']);
        }
        
        
// ########## START THREAD CREATION ##########
        
$forumid $pmoptions['regforum'];
        
$foruminfo fetch_foruminfo($forumid);
        
$post[title] = $pmoptions['regpmtitle'];
        
$post[message] = $pmoptions['regpmtext'];
        
$post[poststarttime] = TIMENOW;
        
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
        
$post['emailupdate'] = 9999;
        
build_new_post('thread'$foruminfo, array(), 0$post$errors);
        
// ########## END THREAD CREATION ##########

        // ########## START SEND PM TO USER ##########
        
$from_userid 3;
        
$from_username theacoustician;
        
$welcome_thread $post['threadid']; //thread id of thread created above

        
$to_userid $bbuserinfo['userid'];
        
$to_username $bbuserinfo['username'];

        
$title "Important information regarding your registration!";
        
$message "Pending your full approval, we have created a thread for you.  The thread is located [url=http://uselessforums.com/showthread.php?t=" $welcome_thread "]here[/url].  This will be the only thread you can post in until an administrator approves your membership.  If you have any questions that you'd rather not post, feel free to reply to this private message.";
        
$iconid 0;
        
$signature=1// 1 to show sig, 0 to hide it
        
$disablesmilies=1// 1 to hide smilies, 0 to show them

        // build touserarray
        
$tostring=array($to_userid => $to_username);

        
// store the message
        
$DB_site->query("INSERT INTO " TABLE_PREFIX "pmtext\n\t(fromuserid, fromusername, title, message, touserarray, iconid, dateline, showsignature, allowsmilie)\nVALUES\n\t($from_userid, '" mysql_escape_string($from_username) . "', '"mysql_escape_string($title) ."', '"mysql_escape_string($message) ."', '" addslashes(mysql_escape_string($tostring)) . "', $iconid, " TIMENOW ", $signature$disablesmilies)");

        
// get the inserted private message id
        
$pmtextid $DB_site->insert_id();

        
// send in receiving user's inbox
        
$DB_site->query("INSERT INTO " TABLE_PREFIX "pm (pmtextid, userid) VALUES ($pmtextid$to_userid)");

        
// add to PM receiving user's total (with pm-popup)
        
$DB_site->shutdown_query("UPDATE " TABLE_PREFIX "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$to_userid");
        
// ########## END SEND PM TO USER ##########
        
        // ###################################################################
        // # END WELCOME HACK
        // ###################################################################

        
if ($userinfo['coppauser'] OR ($vboptions['moderatenewmembers'] AND !$userinfo['posts'])) 
Reply With Quote
  #7  
Old 06-23-2005, 03:07 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use $user, not $bbuserinfo.

Amy
Reply With Quote
  #8  
Old 06-23-2005, 03:22 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
Use $user, not $bbuserinfo.



Amy
Replace all instances within my code? And can you explain why? Sorry I'm so new to this its hilarious.
Reply With Quote
  #9  
Old 06-23-2005, 04:23 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this:

Code:
// delete activationid
        //$DB_site->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid=$userinfo[userid] AND type=0");

        // ###################################################################
        // # WELCOME HACK
        // ###################################################################

        $username = $user['username'];
        $userid = $user['userid'];
        //$username = $_POST['username'];
        
        // Process each one of the replacement vars
        $vars = array(
            '$bbtitle' => $vboptions['bbtitle'],
            '$username' => $username,
            '$email' => $email,
            '$userid' => $userid
        );
        
        $pmoptions['regpmtext'] = $vboptions['regpmtext'];
        $pmoptions['regpmtitle'] = $vboptions['regpmtitle'];
        $pmoptions['regforum'] = $vboptions['regforum'];
        
        // Now that we have the options, we need to process eaach of the
        // vars we can use
        foreach($vars AS $_key => $_value)
        {
            $pmoptions['regpmtext'] = str_replace($_key, $_value, $pmoptions['regpmtext']);
            $pmoptions['regpmtitle'] = str_replace($_key, $_value, $pmoptions['regpmtitle']);
        }
        
        // ########## START THREAD CREATION ##########
        $forumid = $pmoptions['regforum'];
        $foruminfo = fetch_foruminfo($forumid);
        $post[title] = $pmoptions['regpmtitle'];
        $post[message] = $pmoptions['regpmtext'];
        $post[poststarttime] = TIMENOW;
        //$post[posthash] = md5($post[poststarttime] . $user['userid'] . $user['salt']);
        //$post['emailupdate'] = 9999;
        build_new_post('thread', $foruminfo, array(), 0, $post, $errors);
        // ########## END THREAD CREATION ##########

        // ########## START SEND PM TO USER ##########
        $from_userid = 3;
        $from_username = theacoustician;
        $welcome_thread = $post['threadid']; //thread id of thread created above

        $to_userid = $user['userid'];
        $to_username = $user['username'];

        $title = "Important information regarding your registration!";
        $message = "Pending your full approval, we have created a thread for you.  The thread is located here.  This will be the only thread you can post in until an administrator approves your membership.  If you have any questions that you'd rather not post, feel free to reply to this private message.";
        $iconid = 0;
        $signature=1; // 1 to show sig, 0 to hide it
        $disablesmilies=1; // 1 to hide smilies, 0 to show them

        // build touserarray
        $tostring=array($to_userid => $to_username);

        // store the message
        $DB_site->query("INSERT INTO " . TABLE_PREFIX . "pmtext\n\t(fromuserid, fromusername, title, message, touserarray, iconid, dateline, showsignature, allowsmilie)\nVALUES\n\t($from_userid, '" . mysql_escape_string($from_username) . "', '". mysql_escape_string($title) ."', '". mysql_escape_string($message) ."', '" . addslashes(mysql_escape_string($tostring)) . "', $iconid, " . TIMENOW . ", $signature, $disablesmilies)");

        // get the inserted private message id
        $pmtextid = $DB_site->insert_id();

        // send in receiving user's inbox
        $DB_site->query("INSERT INTO " . TABLE_PREFIX . "pm (pmtextid, userid) VALUES ($pmtextid, $to_userid)");

        // add to PM receiving user's total (with pm-popup)
        $DB_site->shutdown_query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$to_userid");
        // ########## END SEND PM TO USER ##########
        
        // ###################################################################
        // # END WELCOME HACK
        // ###################################################################
Note, I haven't tested it. But, I try to use the variables the native code is using. It was using $user, which I know will be fully defined.
Reply With Quote
  #10  
Old 06-23-2005, 04:30 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I shall try that. Thanks!

fdsfsdfsfsdfsdf

Hmmm... That didn't seem to work. The PM never got sent and the thread title that got created didn't include their name.

The thread title = $pmoptions['regpmtitle'] = $vboptions['regpmtitle'] = Please welcome $username to UF

fsdafsdfafdsfdsa

wtf, it keeps merging my posts. Please see my reply above about it not working...
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:04 PM.


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.04626 seconds
  • Memory Usage 2,317KB
  • Queries Executed 13 (?)
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_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete