我正在使用joomla 1.7,我希望一些用户没有插入用户名的选项。
我试图设置,在注册(说的用户)系统将保存输入的电子邮件在用户名字段和电子邮件字段,并从表单中删除用户名文本框。
我知道我需要在某个地方插入$data['username'] = $data['email']
,但我找不到正确的位置。我试图将其放在public function register($temp)
下的注册模型中,但没有成功。我找不到另一个合乎逻辑的地方来放它。
// Prepare the data for the user object.
$data['my_teacher'] = $data['my_teacher'];
$data['email'] = $data['email1'];
$data['username'] = $data['email1'];
$data['password'] = $data['password1'];
$useractivation = $params->get('useractivation');
我找到了这样做的方法只需添加
if(isset($temp['email1'])){
$temp['username'] = $temp['email1'];
}
$temp = (array)$app->getUserState('com_users.registration.data', array());
然后从.xml中删除"username"字段,并在views/registration/tmpl
中的default.php文件中添加一个名为:jform[username]和id:jform_username的隐藏字段。行是这样的
<input type="text" name="jform[username]" id="jform_username" value="<?php echo 'something.random.that.will.be.replaced.with.the.email'; ?>" style="visibility:hidden;">
我说的所有文件都在/components/com_users/
下http://extensions.joomla.org/extensions/access-a-security/authentication/10343
上述扩展将删除用户在注册时输入用户名的需要。但是,它会根据name字段生成一个用户名。它只在最后才使用电子邮件地址作为用户名,因为这可能会导致Joomla中的某些扩展出现问题。它还允许用户使用他们的电子邮件地址登录。
迪伦