Accessing IPB Classes Externally From Main Website

2019-06-11 21:02发布

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

标签: php forum ipb
2条回答
看我几分像从前
2楼-- · 2019-06-11 21:27

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');
查看更多
\"骚年 ilove
3楼-- · 2019-06-11 21:38

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');
查看更多
登录 后发表回答