Announcement

Collapse
No announcement yet.

Custom Form User Registration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Form User Registration

    I need to develop a custom form in my CMS to register a user in vBulletin. Where can I find some basic instruction on how to pass the variables and data to vBulletin, especially the password and encryption? I know basic php coding and I can code this as long as I can find the basic instructions.
    Thanks

  • #2
    If the CMS is on the same server - https://forum.vbulletin.com/blogs/da...n-your-website

    vBulletin should run under SSL for the best login security.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud customization and demonstration site.
    vBulletin 5 Documentation - Updated every Friday. Report issues here.
    vBulletin 5 API - Full / Mobile
    I am not currently available for vB Messenger Chats.

    Comment


    • #3
      Thank you for your quick reply. Yes. it is on the same server but separate MySQLi database. the link you shared is for the log in process which I already have it working. I need instructions on how to register a new user. Thank you again in advance.

      Comment


      • #4
        You would call the save() method of vB_Api_User - http://vb5support.com/resources/mapi...ml#method_save

        /core/vb/api/user.php
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
        vBulletin 5 Documentation - Updated every Friday. Report issues here.
        vBulletin 5 API - Full / Mobile
        I am not currently available for vB Messenger Chats.

        Comment


        • #5
          Thank you for your reply.
          Would you be able to help me with example code on how to do this? I'm not sure how to use that save function.
          All I need is to save the username, email, password (token and secret), and set the user group as "Registered user".

          Comment


          • #6
            You only need to send the text of the password. vBulletin will generate the hash and salt for it.

            Code:
            $userId = $userApi->save(0, getPassword(), $user, array(), array(), array());
            Look at https://github.com/wayneluke/vbFaker...reateUsers.php

            I am using it to create fake users but the principle is the same. The file was created for personal use so there isn't much documentation in it but the buildUser() function shows how I create an array to be sent to the database through the API. The user array contains username, birthday, usergroupid, and ipaddress. You can include any field in the user table in the database. The getPassword() function just generates a random password for each user. All data is randomized and generated by the script.
            Last edited by Wayne Luke; Thu 15th Aug '19, 8:33am.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud customization and demonstration site.
            vBulletin 5 Documentation - Updated every Friday. Report issues here.
            vBulletin 5 API - Full / Mobile
            I am not currently available for vB Messenger Chats.

            Comment


            • #7
              Wayne,
              Thank you for your reply.
              As I said, I'm not an expert in coding so I will be bothering you a lot, hopefully, I'll get it right soon.

              Here is what I have so far (which is not working). Not sure what is missing/wrong.


              PHP Code:
              // Path to your vBulletin installation
              $vbpath 'forum';

              // Start script
              require_once($vbpath '/includes/vb5/autoloader.php');
              vB5_Autoloader::register($vbpath);

              //init the vBulletin system
              require_once($vbpath '/core/vb/vb.php');
              vB::init();

              //get user info
              $user ['username'] =  $_POST['username'];
              $user ['email'] =  $_POST['email'];

              //Create new user
              $userApi vB_Api::instance('user');
              $userId $userApi->save(0$_POST['password'], $user); 
              I appreciate your help.

              Comment


              • #8
                I had to add the three empty arrays at the end in my statement. Even though I wasn't setting any values in those arrays.
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                vBulletin 5 Documentation - Updated every Friday. Report issues here.
                vBulletin 5 API - Full / Mobile
                I am not currently available for vB Messenger Chats.

                Comment


                • #9
                  Thanks,
                  So I added the three arrays, but still nothing is happening. No user is being added to the database.
                  Here is my code

                  PHP Code:
                  // Path to your vBulletin installation
                  $vbpath 'forum';

                  // Start script
                  require_once($vbpath '/includes/vb5/autoloader.php');
                  vB5_Autoloader::register($vbpath);

                  //init the vBulletin system
                  require_once($vbpath '/core/vb/vb.php');
                  vB::init();

                  //get user info
                  $user ['username'] =  $_POST['username'];
                  $user ['email'] =  $_POST['email'];

                  //Create new user
                  $userApi vB_Api::instance('user');
                  $userId $userApi->save(0$_POST['password'], $user, array(), array(), array()); 

                  Comment


                  • #10
                    If you look at the code that I linked above, you should see a session is created using an administrator user. I don't see this here.

                    Code:
                    vB::setRequest(new vB_Request_Cli (
                    array(
                    'userid' => 1,
                    'ipAddress' => '127.0.0.1',
                    'altIp' => '127.0.0.1',
                    'userAgent' => 'CLI'
                    )
                    ));
                    vB::getRequest()->createSession();
                    vB::getCurrentSession()->fetchCpsessionHash();
                    Last edited by Wayne Luke; Fri 16th Aug '19, 2:51pm.
                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                    vBulletin 5 Documentation - Updated every Friday. Report issues here.
                    vBulletin 5 API - Full / Mobile
                    I am not currently available for vB Messenger Chats.

                    Comment


                    • #11
                      I am not that big of a programmer either. Haven't really dealt with code professionally for over 20 years. I just hack it together until it works. Looking at the source code for the classes you're using help.

                      That is one of the reasons I put together the API documentation and the MAPI documentation.
                      Translations provided by Google.

                      Wayne Luke
                      The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                      vBulletin 5 Documentation - Updated every Friday. Report issues here.
                      vBulletin 5 API - Full / Mobile
                      I am not currently available for vB Messenger Chats.

                      Comment


                      • #12
                        You are tremendous help and way better programmer than I am and I truly appreciate your support.
                        After adding the session section, here is what I have

                        PHP Code:
                        // Path to your vBulletin installation
                        $vbpath 'forum';

                        // Start script
                        require_once( $vbpath '/includes/vb5/autoloader.php' );
                        vB5_Autoloader::register$vbpath );

                        //init the vBulletin system
                        require_once( $vbpath '/core/vb/vb.php' );
                        vB::init();

                        //Start Session
                        vB::setRequest( new vB_Request_Cli(
                          array(
                            
                        'userid' => 1,
                            
                        'ipAddress' => '127.0.0.1',
                            
                        'altIp' => '127.0.0.1',
                            
                        'userAgent' => 'CLI'
                          
                        )
                        ) );
                        vB::getRequest()->createSession();
                        vB::getCurrentSession()->fetchCpsessionHash();


                        //get user info
                        $user'username' ] = $_POST'username' ];
                        $user'email' ] = $_POST'email' ];

                        //Create new user
                        $userApi vB_Api::instance'user' );
                        $userId $userApi->save0$_POST'password' ], $user, array(), array(), array() ); 

                        With this I'm getting the following error message:
                        HTML Code:
                        cannot use vB CLI scripts from the web

                        Comment


                        • #13
                          I did not done a full external register form yet, but I think you should not register an admin before registering a new user?!
                          If you disable humanverification for register it is totally easy to register a new user from an external website. But I did not try hardly with enabled hv... I failed with a short test in the past and didn't need it until then.
                          vBulletin-Forum.de closed!

                          Comment


                          • #14
                            Personally, would process the registration in the CMS and then pass that information to a CLI script that triggers the registration on vBulletin. I would not do this from a web accessible script without using the full Mobile API and its authentication routines.

                            You might want to use the code in the original blog entry.
                            Translations provided by Google.

                            Wayne Luke
                            The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                            vBulletin 5 Documentation - Updated every Friday. Report issues here.
                            vBulletin 5 API - Full / Mobile
                            I am not currently available for vB Messenger Chats.

                            Comment

                            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                            Working...
                            X