Creating new Users through API

manf

Member
Hello,
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.
 
The user datawriter can be used here:

XenForo_DataWriter_User

You can see it being used in this action:

XenForo_ControllerPublic_Register::actionRegister

That is this file:

library/XenForo/ControllerPublic/Register.php
 
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:

PHP:
    $startTime = microtime(true);
    $fileDir = dirname(__FILE__);
 
    require($fileDir . '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
 
    XenForo_Application::initialize($fileDir . '/library', $fileDir);
    XenForo_Application::set('page_start_time', $startTime);

Each time i visit the script im told to come back later.

How can i load the files correctly?
 
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.
 
Enable debug mode by adding this line to your library/config.php file:

Code:
$config['debug'] = 1;

That may reveal a more detailed error message.
 
Thanks!
I managed to fix my errors, now its working perfectly.
Your support was really awesome Jake.
:)
 
Back
Top Bottom