1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating new Users through API

Discussion in 'XenForo Development Discussions' started by manf, Mar 23, 2013.

  1. manf

    manf Member

    im new to XenForo and i'd like to create a new User. Basically i want to create the User externally without redirecting to the built-in solution. I managed to develop this based on another Software. Now i need to convert my old script to XenForo.

    Actually i just need to find complementary functions, but i dont find a starting point.

    Im looking for these Functions:
    • isValidUsername/Email --> Is this Username/Email allowed? (Only consising of normal characters)
    • isAvailableUsername/Email --> Is this Username/email never used?
    • createUser --> Just create a new user with given password, username and email
    • sendActivationEmail --> Just giving the user the opportunity to activate himself
    Im still analysing XenForo's structur, but it's quite heavy for beginners to get along with.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The user datawriter can be used here:


    You can see it being used in this action:


    That is this file:

  3. manf

    manf Member

    Thanks Jake,
    but im still having problems including the autoloader to load the classes. Im using the same way the index.php is loading it:

        $startTime microtime(true);
    $fileDir dirname(__FILE__);
    $fileDir '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir '/library');
    XenForo_Application::initialize($fileDir '/library'$fileDir);
    Each time i visit the script im told to come back later.

    How can i load the files correctly?
  4. Jeremy

    Jeremy Well-Known Member

    Is the PHP file that you are attempting to find located in the root of your XF director, or is it outside of your XF directory? dirname() will return the file of the path its in. Which may be setting up your autoloader incorrectly.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Exact error?
  6. manf

    manf Member

    No, i included this file in the same folder.
    - test.php (that file)

    This is my error:
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Enable debug mode by adding this line to your library/config.php file:

    $config['debug'] = 1;
    That may reveal a more detailed error message.
  8. manf

    manf Member

    I managed to fix my errors, now its working perfectly.
    Your support was really awesome Jake.

Share This Page