Accessing IPB Classes Externally From Main Website

余生长醉 提交于 2020-01-03 05:49:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!