私は単純な「アカウントの作成」フォームを html で作成しました。このフォームは、ダブル オプトイン メソッドのために Java と連携するように結び付けられています。また、このフォームで Joomla にユーザーを作成し、[アカウントの作成] ボタンをクリックした後にログインさせたいと思います。
ダブルオプトインは正常に機能しますが、joomla 2.5 の新しいユーザースクリプトは機能せず、エラーはありませんが、ユーザーを登録しません。新しいユーザーを生成するために、stackoverflow にある php スクリプト (以下を参照) を配置しようとしましたが、うまくいきません。
これら 2 種類のスクリプトを 1 つのフォームで一緒に実行することはできますか? もしそうなら、どこが間違っていますか?ありがとう!
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
//Check for request forgeries, we comment this out since tokens are not generated in the html page
//JRequest::checkToken() or jexit( 'Invalid Token' );
//Get required system objects
$user = clone(JFactory::getUser());
$pathway = & $mainframe->getPathway();
$config = & JFactory::getConfig();
$authorize = & JFactory::getACL();
$document = & JFactory::getDocument();
//If user registration is not allowed, show 403 not authorized(Not needed)
$usersConfig = &JComponentHelper::getParams( 'com_users' );
if ($usersConfig->get('allowUserRegistration') == '0')
{
JError::raiseError( 403, JText::_( 'Access Forbidden' ));
return;
}
//Initialize new usertype setting
$newUsertype = $usersConfig->get( 'new_usertype' );
if (!$newUsertype)
{
$newUsertype = 'Registered';
}
//Bind the post array to the user object
if (!$user->bind( JRequest::get('post'), 'usertype' ))
{
JError::raiseError( 500, $user->getError());
}
//Set some initial user values
$user->set('id', 0);
$user->set('usertype', '');
$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
$date =& JFactory::getDate();
$user->set('registerDate', $date->toMySQL());
//If user activation is turned on, we need to set the activation information(Not needed)
$useractivation = $usersConfig->get( 'useractivation' );
if ($useractivation == '1')
{
jimport('joomla.user.helper');
$user->set('activation', md5( JUserHelper::genRandomPassword()) );
$user->set('block', '1');
}
//Save the details of the user
$user->save();