SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with vbulletin php code please

    Hi,
    Im really new to coding and only just finished my first vbulletin modification, however I seem to be having one issue with the code.

    The code has two parts/options.
    Option one allows a "welcome thread" to be created as soon as a member registers on the forum. This is working perfectly.

    The second option is to allow the "welcome thread" to be created after a member has confirmed their email address. This is where im having the problem! I'll give a little example.

    Member 1 registers and is logged in. Member 1 receives email and verifies email address whilst logged in still - thread is created with the members username in the title.

    Member 2 registers and logs off

    Member 3 registers and logs off

    Member 2 receives email and clicks on link to verify email address. The "Congratulations etc etc, you may now edit your profile etc" message is posted, however the member is not automatically logged in. They have to put in there username and password.
    This seems to be creating an issue, because the member is not actually logged in when they verify their email address, the welcome thread message displays "Our new member - Unregistered" instead of "Our new member - Dave"

    Is there any easy way to solve this, as at the moment im really struggling, and being new to learning the code doesn't really help! Maybe some kind of way to delay the thread being created until they have actually logged in after confirming their email address, this should then solve the issue of it showing "Unregistered" and not $username.

    Ive attached a copy of the code. The part im talking about starts from line 91. The section above that is if the email verification isnt selected.
    Any help is greatly appreciated.

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    South Florida
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think he has to login, its a issue with the PHP code you did. It need to wait until he click email verification link and verify email address. Post the code if possible so we can see what exactly happening

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, its really appreciated. I thought I added it as an attachment however ive just checked and it dosent support xml.

    PHP Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <product productid="welcomethread280509" active="1">
        <title>Welcome Thread</title>
        <description>Creates a welcome thread when a new user registers</description>
        <version>1.2</version>
        <url></url>
        <codes>
        </codes>
        <templates>
        </templates>
        <plugins>
            <plugin active="1">
                <title>welcome thread upon registration</title>
                <hookname>register_addmember_complete</hookname>
                <phpcode><![CDATA[if ($vbulletin->options['wtur_active'] AND $vbulletin->options['wtur_activewhen'] == 1)
                {
        
        // Backend Files
        require_once('./global.php');
        require_once('./includes/class_dm.php');
        require_once('./includes/class_dm_threadpost.php');
        require_once('./includes/functions_databuild.php');

    $threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
    $foruminfo = fetch_foruminfo($foruminfo['forumid']);
    $threadinfo = array();
    $username = $vbulletin->userinfo['username'];  
    $forumid = $vbulletin->options['wtur_fid'];
    eval('$title1 = "' . addslashes($vbulletin->options['wtur_title1']) . '";');  
    eval('$title2 = "' . addslashes($vbulletin->options['wtur_title2']) . '";');
    eval('$title3 = "' . addslashes($vbulletin->options['wtur_title3']) . '";');
    eval('$title4 = "' . addslashes($vbulletin->options['wtur_title4']) . '";');
    $title = array("$title1", "$title2", "$title3", "$title4");
    $rand_title = array_rand($title, 4);
    $wtur_userids_get = explode(",", $vbulletin->options['wtur_postinguserid']);
    $wtur_userids = $wtur_userids_get[array_rand($wtur_userids_get)];
    $wtur_userid = fetch_userinfo($wtur_userids);
    eval('$pagetext1 = "' . addslashes($vbulletin->options['wtur_content1']) . '";');
    eval('$pagetext2 = "' . addslashes($vbulletin->options['wtur_content2']) . '";');
    eval('$pagetext3 = "' . addslashes($vbulletin->options['wtur_content3']) . '";');
    eval('$pagetext4 = "' . addslashes($vbulletin->options['wtur_content4']) . '";');
    $pagetext = array("$pagetext1", "$pagetext2", "$pagetext3", "$pagetext4");
    $rand_text = array_rand($pagetext, 4);
    $wtur_posticons_get = explode(",", $vbulletin->options['wtur_posticon']);
    $wtur_posticons = $wtur_posticons_get[array_rand($wtur_posticons_get)];
    $allowsmilie = '1';
    $visible = $vbulletin->options['wtur_moderate'];

    $threaddm->set_info('forum', $foruminfo);
    $threaddm->set_info('thread', $threadinfo);
    $threaddm->setr('forumid', $forumid);
    $threaddm->setr('userid', $wtur_userid['userid']);
    $threaddm->setr('pagetext', $pagetext[$rand_text[0]]);
    $threaddm->setr('title', $title[$rand_title[0]]);
    $threaddm->set('iconid', $wtur_posticons['iconid']);
    $threaddm->set('allowsmilie', $allowsmilie);
    $threaddm->set('visible', $visible);


    $threaddm->pre_save();
    if(count($threaddm->errors) < 1)
    {
        $threadid = $threaddm->save();
        unset($threaddm);
        build_thread_counters($threaddm);
    }
     build_forum_counters($forumid);
     
     // update post count for user
        $posts = $vbulletin->db->query_first("
            SELECT posts
            FROM " . TABLE_PREFIX . "user
            WHERE userid = ".$wtur_userid['userid']."
        ");
        
        $newpostcount = $posts['posts'] + 1;
        
        $vbulletin->db->free_result($posts);
        
        $vbulletin->db->query_write("
            UPDATE " . TABLE_PREFIX . "user
            SET posts = ".$newpostcount."
            WHERE userid = ".$wtur_userid['userid']."
        ");  
     
     
     ]]>}</phpcode>
            </plugin>
            
            <plugin active="1">
                <title>welcome thread upon registration</title>
                <hookname>register_activate_process</hookname>
                <phpcode><![CDATA[if ($vbulletin->options['wtur_active'] AND $vbulletin->options['wtur_activewhen'] == 0)
                {
        
        // Backend Files
        require_once('./global.php');
        require_once('./includes/class_dm.php');
        require_once('./includes/class_dm_threadpost.php');
        require_once('./includes/functions_databuild.php');

    $threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
    $foruminfo = fetch_foruminfo($foruminfo['forumid']);
    $threadinfo = array();
    $username = $vbulletin->userinfo['username'];  
    $forumid = $vbulletin->options['wtur_fid'];
    eval('$title1 = "' . addslashes($vbulletin->options['wtur_title1']) . '";');  
    eval('$title2 = "' . addslashes($vbulletin->options['wtur_title2']) . '";');
    eval('$title3 = "' . addslashes($vbulletin->options['wtur_title3']) . '";');
    eval('$title4 = "' . addslashes($vbulletin->options['wtur_title4']) . '";');
    $title = array("$title1", "$title2", "$title3", "$title4");
    $rand_title = array_rand($title, 4);
    $wtur_userids_get = explode(",", $vbulletin->options['wtur_postinguserid']);
    $wtur_userids = $wtur_userids_get[array_rand($wtur_userids_get)];
    $wtur_userid = fetch_userinfo($wtur_userids);
    eval('$pagetext1 = "' . addslashes($vbulletin->options['wtur_content1']) . '";');
    eval('$pagetext2 = "' . addslashes($vbulletin->options['wtur_content2']) . '";');
    eval('$pagetext3 = "' . addslashes($vbulletin->options['wtur_content3']) . '";');
    eval('$pagetext4 = "' . addslashes($vbulletin->options['wtur_content4']) . '";');
    $pagetext = array("$pagetext1", "$pagetext2", "$pagetext3", "$pagetext4");
    $rand_text = array_rand($pagetext, 4);
    $wtur_posticons_get = explode(",", $vbulletin->options['wtur_posticon']);
    $wtur_posticons = $wtur_posticons_get[array_rand($wtur_posticons_get)];
    $allowsmilie = '1';
    $visible = $vbulletin->options['wtur_moderate'];

    $threaddm->set_info('forum', $foruminfo);
    $threaddm->set_info('thread', $threadinfo);
    $threaddm->setr('forumid', $forumid);
    $threaddm->setr('userid', $wtur_userid['userid']);
    $threaddm->setr('pagetext', $pagetext[$rand_text[0]]);
    $threaddm->setr('title', $title[$rand_title[0]]);
    $threaddm->set('iconid', $wtur_posticons['iconid']);
    $threaddm->set('allowsmilie', $allowsmilie);
    $threaddm->set('visible', $visible);


    $threaddm->pre_save();
    if(count($threaddm->errors) < 1)
    {
        $threadid = $threaddm->save();
        unset($threaddm);
        build_thread_counters($threaddm);
    }
     build_forum_counters($forumid);
     
     // update post count for user
        $posts = $vbulletin->db->query_first("
            SELECT posts
            FROM " . TABLE_PREFIX . "user
            WHERE userid = ".$wtur_userid['userid']."
        ");
        
        $newpostcount = $posts['posts'] + 1;
        
        $vbulletin->db->free_result($posts);
        
        $vbulletin->db->query_write("
            UPDATE " . TABLE_PREFIX . "user
            SET posts = ".$newpostcount."
            WHERE userid = ".$wtur_userid['userid']."
        ");  
     
     ]]>}</phpcode>
            </plugin>        
        </plugins>
        <phrases>
                
                <phrasetype name="vBulletin Settings" fieldname="vbsettings">
                <phrase name="settinggroup_newthreadupon" date="0" username="powerful_rogue" version="1.2"><![CDATA[Welcome Thread Upon Registration]]></phrase>
                <phrase name="setting_wtur_active_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Enabled?]]></phrase>
                <phrase name="setting_wtur_active_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Active]]></phrase>
                 <phrase name="setting_wtur_content1_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[ $username and BBcode can be used <br /><br /> If you do not wish the thread content to be random, copy and paste the same text into the three boxes below.]]></phrase>
                 <phrase name="setting_wtur_content1_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Content One]]></phrase>
                 <phrase name="setting_wtur_title1_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Use $username to insert the new members name in the title. <br /><br /> If you do not wish the title to be random, copy and paste the same content into the three boxes below.]]></phrase>
                 <phrase name="setting_wtur_title1_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[ Thread Title One]]></phrase>
                 <phrase name="setting_wtur_fid_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Enter the forum ID of where you wish the new thread to be posted]]></phrase>
                 <phrase name="setting_wtur_fid_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Forum ID]]></phrase>
                 <phrase name="setting_wtur_postinguserid_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Enter the User ID(s) of who you wish the new thread to be created by<br /><br /> If more then one UserID, sepearte using commas. 1,2,3,4]]></phrase>
                 <phrase name="setting_wtur_postinguserid_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[UserID(s) of thread creator]]></phrase>
                 <phrase name="setting_wtur_moderate_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Allow thread to be posted without going into moderation<br />This is useful if new members require admin approval prior to posting]]></phrase>
                 <phrase name="setting_wtur_moderate_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Moderation]]></phrase>
                  <phrase name="setting_wtur_activewhen_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Yes = Before email activation<br /> No = After email activation<br /><br /> If you do not use email activation, leave this set to "Yes"]]></phrase>
                 <phrase name="setting_wtur_activewhen_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Create thread before or after email activation]]></phrase>
                 <phrase name="setting_wtur_posticon_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Default icon is the smiley face.<br /> To chose a different icon, find out the icon number via the "Post Icon Manager" within the ACP<br /><br /> For random icons, seperate using commas. 1,2,3,4]]></phrase>
                 <phrase name="setting_wtur_posticon_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Post icon(s) with new thread]]></phrase>
                 <phrase name="setting_wtur_content2_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[ Random content two]]></phrase>
                 <phrase name="setting_wtur_content2_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Content Two]]></phrase>
                 <phrase name="setting_wtur_title2_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Random title two]]></phrase>
                 <phrase name="setting_wtur_title2_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Title Two]]></phrase>
                  <phrase name="setting_wtur_content3_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[ Random content three]]></phrase>
                 <phrase name="setting_wtur_content3_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Content Three]]></phrase>
                 <phrase name="setting_wtur_title3_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Random title three]]></phrase>
                 <phrase name="setting_wtur_title3_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Title Three]]></phrase>
                  <phrase name="setting_wtur_content4_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[ Random Content Four]]></phrase>
                 <phrase name="setting_wtur_content4_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Content Four]]></phrase>
                 <phrase name="setting_wtur_title4_desc" date="0" username="powerful_rogue" version="1.2"><![CDATA[Randon title four]]></phrase>
                 <phrase name="setting_wtur_title4_title" date="0" username="powerful_rogue" version="1.2"><![CDATA[Thread Title Four]]></phrase>
    </phrasetype>
        </phrases>
        <options>
        
        <settinggroup name="newthreadupon" displayorder="20874">
                <setting varname="wtur_active" displayorder="10">
                    <datatype>boolean</datatype>
                    <optioncode>yesno</optioncode>
                    <defaultvalue>1</defaultvalue>
                    </setting>
                    <setting varname="wtur_activewhen" displayorder="20">
                    <datatype>boolean</datatype>
                    <optioncode>yesno</optioncode>
                    <defaultvalue>1</defaultvalue>
                    </setting>
                    <setting varname="wtur_moderate" displayorder="30">
                    <datatype>boolean</datatype>
                    <optioncode>yesno</optioncode>
                    <defaultvalue>1</defaultvalue>
                    </setting>
                    <setting varname="wtur_fid" displayorder="40">
                    <datatype>number</datatype>
                    <defaultvalue>1</defaultvalue>
                        </setting>
                        <setting varname="wtur_postinguserid" displayorder="50">
                    <datatype>free</datatype>
                    <defaultvalue>1</defaultvalue>
                </setting>
                <setting varname="wtur_posticon" displayorder="60">
                    <datatype>free</datatype>
                    <defaultvalue>7</defaultvalue>
                </setting>
                    <setting varname="wtur_title1" displayorder="70">
                    <datatype>free</datatype>
                    <defaultvalue>Welcome $username</defaultvalue>
                </setting>
                    <setting varname="wtur_content1" displayorder="110">
                    <datatype>free</datatype>
                    <optioncode>textarea</optioncode>
                    <defaultvalue>Hi $username, welcome to the forum!</defaultvalue>
                </setting>
                <setting varname="wtur_title2" displayorder="80">
                    <datatype>free</datatype>
                    <defaultvalue>$username has joined!</defaultvalue>
                </setting>
                    <setting varname="wtur_content2" displayorder="120">
                    <datatype>free</datatype>
                    <optioncode>textarea</optioncode>
                    <defaultvalue>Welcome $username, Glad you have joined!</defaultvalue>
                </setting>
                <setting varname="wtur_title3" displayorder="90">
                    <datatype>free</datatype>
                    <defaultvalue>$username is our latest member!</defaultvalue>
                </setting>
                    <setting varname="wtur_content3" displayorder="130">
                    <datatype>free</datatype>
                    <optioncode>textarea</optioncode>
                    <defaultvalue>$username! Thank you for joining</defaultvalue>
                </setting>
                <setting varname="wtur_title4" displayorder="100">
                    <datatype>free</datatype>
                    <defaultvalue>We have a new member - $username</defaultvalue>
                </setting>
                    <setting varname="wtur_content4" displayorder="140">
                    <datatype>free</datatype>
                    <optioncode>textarea</optioncode>
                    <defaultvalue>Glad you could find us $username!</defaultvalue>
                </setting>
                </settinggroup>
        </options>
    </product>

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    South Florida
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like a XML plugin for vBulletin, did you just upload this XML plugin or did you do any changes to PHP files manually. Did you do this hack/changes by your self of did you download a modification from another vBulletin forums, if so check their forums, usually they should have a thread discussing all the associated issues.

  5. #5
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This is an xml plugin for vbulletin that I wrote myself. Its working 99%, apart from the one little glitch I mentioned in the first post which for some reason I cant seem to work out how to solve it.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not familiar with vbulletins code and system at all, but when a user clicks the activation link, theres probably some sort of id in the query string. In some database table, this id is stored, and there is a way to identify which user that id was issued to. They probably store a user id along with the activation id.

    My point being, there is a way to query the database using the activation id, in order to get the user id. The user id can be used to retrieve the user name. You just may need to play cat and mouse a bit.

  7. #7
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you I can see where your coming from, its now just a case of trying to put it into practice.

    Ive had a look at the vbulletin database and there is a table called "useractivation"

    Ive attached a couple of screen shots. Would you have any suggestions in relation to the kind of sql query I would need and how I would be able to implement this into the code?

    I apologies for asking a lot, however I am very new to coding and still picking it up a bit at a time.

    Any help really is greatly appreciated.

    Thanks
    Dave



    Attached Images Attached Images

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SELECT u.username
      FROM " . TABLE_PREFIX . "user u
    INNER
      JOIN " . TABLE_PREFIX . "useractivation ua
        ON ua.userid = u.userid
     WHERE ua.activationid = '959d97...'
    I think that would grab the username. It looks in the useractivation table for the given activation id. If found, it will try to find a matching row in the user table where the userid matches.

    I'm not sure how you would get the activationid, but it's prob in a variable. I don't know how they use the other columns in the activation table. There's a chance you may be bypassing some type of security check or other functionality/logic by doing this.

    You may want to do something to make sure you don't spam multiple welcome posts if the user refreshes the page and stuff like that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •