2014-03-05 2 views
0

joomla의 사용자 정의 등록 스크립트가 있는데 문제없이 작동하지만 지금은 주소 및 셀룰러 번호와 같은 '프로필'필드를 추가하고 싶습니다. 프로필 필드가있는 Joomla 사용자 정의 등록 스크립트

가 어떻게 프로파일 DB를 추가 할 수 있습니다

'profile.address1' => $indirizzo, 
    'profile.city' => $citta, 
    'profile.phone' => $cellulare, 

하지만 그것은 작동하지 않습니다 ... :이 코드를 추가 한

<?php 
if($_POST["name"] || $_POST["email"] || $_POST["username"] || $_POST["password"]){ 
    define('_JEXEC', 1); 
    define('JPATH_BASE', dirname(__FILE__)); 
    define('DS', DIRECTORY_SEPARATOR); 
    require_once (JPATH_BASE .DS.'includes'.DS.'defines.php'); 
    require_once (JPATH_BASE .DS.'includes'.DS.'framework.php'); 

    $app = JFactory::getApplication('site'); 
    $app->initialise(); 
    require_once(JPATH_BASE.DS.'components'.DS.'com_users'.DS.'models'.DS.'registration.php'); 

    $lang = JFactory::getLanguage(); 
    $extension = 'com_users'; 
    $base_dir = JPATH_SITE; 
    $language_tag = 'it-IT'; 
    $reload = true; 
    $lang->load($extension, $base_dir, $language_tag, $reload); 

    $model = new UsersModelRegistration(); 
    jimport('joomla.mail.helper'); 
    jimport('joomla.user.helper'); 

    $username = $_POST['username']; 
    $name = $_POST['name']; 
    $email = $_POST['email']; 
    $block = '0'; 
    $sendEmail = '1'; 
    $activation = ''; 
    $data = array('username' => $username, 
    'name' => $name, 
    'email1' => $email, 
    'password1' => $password, // First password field 
    'password2' => $password, // Confirm password field 
    'sendEmail' => $sendEmail, 
    'activation' => $activation, 
    'block' => 0); 
     echo $model->register($data); 
} 
?> 

:

내 코드입니다 필드를이 등록 스크립트에 넣으시겠습니까?

고맙습니다.

답변

0

우선 joomla의 Jinput을 사용하여 POST이 아닌 요청 데이터를 검색하는 것이 좋습니다. 자세한 내용은 here에서 확인할 수 있습니다.

개체에 원하는 데이터가 없으므로 사용중인 profile이 작동하지 않습니다. joomla 버전에 따라 $indirizzo, $citta, $cellulare이 속한 곳을 확인하고 해당 객체가있는 객체에 액세스합니다.

$user 개체를 인스턴스화 한 다음 원하는 내용을 검색하는 것이 좋습니다 ($user = JFactory::getUser();). 이 링크는 Accessing the current user objectJFactory/getUser에 도움이됩니다.

+0

링크에는 프로필 입력란에 대한 참조가 없습니다. '$ profile = JUserHelper :: getProfile ($ user-> id);'를 추가했는데 user 필드를 읽을 수는 있지만 user_profiles db에 새로운 id 필드를 생성 할 수는 없습니다. – Kerberos

관련 문제