Joomla用户注册插件字段

时间:2014-08-01 15:49:02

标签: php joomla joomla3.0

我有一个插件,在profile.xml中有一个下拉列表。

profiles / profile.xml

    <?xml version="1.0" encoding="utf-8"?>

    <form>
    <fields name="rqegroup">
    <fieldset name="rqegroup" class="rqegroup_field">  
    <field 
    name="rqe_user_group" 
    type="sql" 
    description="PLG_USER_PROFILE_QQQ"
    default="2" 
    label="Select an article" 
    query="SELECT id, groupname FROM #__xxx_yyyy" 
    key_field="id" 
    value_field="groupname" />

   </fieldset>
   </fields>

profiles1.php

<?php
defined('_JEXEC') or die('(@)|(@)');

jimport('joomla.plugin.plugin');


class plgUserRqeuseragent extends JPlugin
{
    protected $my_var = null; // if needed

    public function __construct(& $subject, $config)
    {
        parent::__construct($subject, $config);
        $this->loadLanguage();
    }


function onContentPrepareForm($form, $data)
        {
                $lang = JFactory::getLanguage();
                $lang->load('plg_user_rqegroup', JPATH_ADMINISTRATOR);

if (!($form instanceof JForm))
        {
            $this->_subject->setError('JERROR_NOT_A_FORM');
            return false;
        }

        $name = $form->getName();
        if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration')))
        {
            return true;
        }

        JForm::addFormPath(__DIR__ . '/profiles');
        $form->loadFile('profile', false);



        return true;

}

    public function onUserAfterSave($user, $isnew, $success, $msg)
    {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$columns = array(
    'login', 
    'name',
    'jid'
);
$values = array(
    "'".$user['username']."'", 
    "'".$user['name']."'", 
    $user['id']
);
$query->insert($db->quoteName('#__qqqq_qqqq'))
    ->columns($db->quoteName($columns))
    ->values(implode(',', $values));
$db->setQuery($query)
    ->execute();    


    }

    public function onUserAfterDelete($user, $succes, $msg)
    {


    }   
}
?>

如何获取profile1.php中字段的值并将其插入数据库?

文件夹结构
profiles / profile.xml
profiles1.php
profiles1.xml

0 个答案:

没有答案