Search code examples
phpforumipb

Accessing IPB Classes Externally From Main Website


Hello I have been working with IPB3.4 and I am trying to have some sort of correlation between my main website and forum, specifically users.

I am aware that you can use the IPBMembers class to simply create a new user however I am unsure how I can initialise that class outside of IPB forum base directory.

If anyone has any experience on this topic I would appreciate any advice.

Thanks


Solution

  • The problem I had from the above script is after the init() method it would redirect me to the forum or cause headers already sent errors so you need to include the below constant for it to work properly outside the IPB forum directories: define( 'IPS_ENFORCE_ACCESS', TRUE );

    $forumPath = '../forums'; //FORUM FOLDER
    define( 'IPS_ENFORCE_ACCESS', TRUE ); // Important so it does not redirect to forums
    define( 'IPB_THIS_SCRIPT', 'public' );
    
    require_once( $forumPath.'/initdata.php' );
    require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
    require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );
    
    $ipbRegistry    = ipsRegistry::instance();
    $ipbRegistry->init();
    
    
    $member = IPSMember::load($memberName, 'all', 'username');