问题
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
回答1:
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');
回答2:
try this from root folder to initialize IPB
define('IPB_THIS_SCRIPT', 'public');
require_once( '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();
then you can use IPSMember like this
$member = IPSMember::load($member_name, 'all', 'username');
来源:https://stackoverflow.com/questions/16311871/accessing-ipb-classes-externally-from-main-website