2012-07-16 55 views
3

我在'管理用户字段'&添加了一个字段,当一封电子邮件发送给管理员通知他们新的用户注册时,我想包括这个新字段。Virtuemart /用户字段

我已经编写了一些代码来从#__vm_user_info中获取这个新字段,它位于/administrator/components/com_virtuemart/classes/ps_shopper.php中的_sendMail函数中,并且将该变量添加到$ message2中。

ASEND_MSG已被修改为接受参数,但是当创建用户时,该字段未包含在发送给管理员的电子邮件中。当我查看表格时,数据就在那里。因此,为了排除故障,我在select语句中硬编码了一个用户名,并添加了另一个用户&为硬编码用户发送了正确的值,而不是刚添加的用户。我现在认为这是MySQL的提交问题,因此我在尝试获取值之前在代码中放置了一个sleep(4)...没有运气。

任何人都可以为我闪耀一些光?

LarryR ....

回答

1
  1. 管理员/组件/ com_virtuemart/classses/ps_shopper.php

之前需要 “返回true” 行与函数add()下面的代码添加:

/* ** * ** * ** * ** * ** * ** * ** * ** * *** ** * ** * ** * ** * ** * ** * ** * **/ $ pwd = $ _POST ['password'];

  $db = JFactory::getDBO(); 

     $query = "SELECT id, name, email, username" 

     . "\n FROM #__users" 

     . "\n ORDER by id DESC LIMIT 1" 

     ; 

     $db->setQuery($query); 

     $rows = $db->loadObjectList(); 

     $namee = $rows[0]->name; 

     $emaill = $rows[0]->email; 

     $usern = $rows[0]->username; 

     $pwd; 

     $lid = $rows[0]->id; 

     $dbv = new ps_DB; 

      echo $query = "SELECT *" 

     . "\n FROM #__{vm}_user_info" 

     . "\n WHERE user_id=$lid" 

     ; 

     $dbv->setQuery($query); 

     $fid = $db->loadObjectList(); 



    $field = $fid[0]->extra_field_1; 

    $user  = clone(JFactory::getUser()); 

    $usersConfig = &JComponentHelper::getParams('com_users'); 

    if ($usersConfig->get('allowUserRegistration') == '0') { 

     JError::raiseError(403, JText::_('Access Forbidden')); 

     return false; 

    } 

    // If user activation is turned on, we need to set the activation information 

    $useractivation = $usersConfig->get('useractivation'); 

    if ($useractivation == '1') 

    { 

     jimport('joomla.user.helper'); 

     $user->set('activation', md5(JUserHelper::genRandomPassword())); 

     $user->set('block', '1'); 

    } 

    $component = 'com_user'; 

    $activation_link = $mosConfig_live_site."/index.php?option=$component&task=activate&activation=".$user->get('activation'); 



    $this->_sendMail($namee , $emaill, $usern, $pwd, $activation_link); 

    /************************************************** Spinz ********************************************/ 

注意:这里我们为用户邮件创建了用户名和密码的邮件功能。

  1. 管理员/组件/ com_virtuemart/classses/ps_shopper.php

需要注释的功能register_save() “返回true” 行前行:

// Send the registration email 

//$this->_sendMail($name, $email, $username, $password, $activation_link); 

注:这里生成的邮件函数我们需要评论该邮件函数,并在第一点中在ps_shopper.php的add()函数中创建另一个邮件函数。

  1. administrator/components/com_virtuemart/classses/ps_shopper。php

需要在函数_sendmail()的jos_vm_user_info表中使用以下代码获取额外的附加字段(extra_field_1),并将该字段通过邮件发送给用户。

/****************************************************************/ 


    $db = JFactory::getDBO(); 

     $query = "SELECT id, name, email, username" 

     . "\n FROM #__users" 

     . "\n ORDER by id DESC LIMIT 1" 

     ; 

     $db->setQuery($query); 

     $rows = $db->loadObjectList(); 

     $lid = $rows[0]->id; 

     $dbv = new ps_DB; 

     $query = "SELECT *" 

     . "\n FROM #__{vm}_user_info" 

     . "\n WHERE user_id=$lid" 

     ; 

     $dbv->setQuery($query); 

     $fid = $db->loadObjectList(); 



    $field = $fid[0]->extra_field_1; 



    $subject = sprintf ($VM_LANG->_('SEND_SUB',false), $name, $mosConfig_sitename); 

    $subject = vmHtmlEntityDecode($subject, ENT_QUOTES); 

    if ($mosConfig_useractivation=="1"){ 

     $message = sprintf ($VM_LANG->_('USEND_MSG_ACTIVATE',false), $name, $mosConfig_sitename, $activation_link, $mosConfig_live_site, $username, $pwd, $field); 

    } else { 

     $message = sprintf ($VM_LANG->_('PHPSHOP_USER_SEND_REGISTRATION_DETAILS',false), $name, $mosConfig_sitename, $mosConfig_live_site, $username, $pwd, $field); 

    } 

/* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ***/

注:

  1. 初始化变量 “$场” 获得使用查询额外添加的字段值。然后额外的字段值由邮件的消息部分分配(初始化变量$字段,在virtmart中增加一个额外字段的值)。

  2. 管理员/组件/ com_virtuemart /语言/普通/英语

替换消息为以下代码:

  1. 'USEND_MSG_ACTIVATE'=>“%s,您好

感谢您在%s注册。您的帐户已创建并且必须先启用才能使用。 要激活账号点击以下链接或在您的浏览器,它复制粘贴: %S

激活后,您可以使用下面的用户名和密码登录到%s:

用户名 - %S 密码 - %S 度 - %s'的

2.'PHPSHOP_USER_SEND_REGISTRATION_DETAILS '=>' %s您好,

谢谢您%s的注册。您的客户帐户已创建。 您可以使用下面的用户名和密码登录到%s:

用户名 - %S 密码 - %S 度 - %S ' 注:指定由

  1. 额外的附加价值语言文件中的字符串%s。

  2. virtuth中包含额外添加字段值的字符串值的消息。

  3. 程度显示添加额外的字段