Advertisement
fancyfiber

Easy Contact Forms - Auto Store Contact information

Mar 27th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1.         $entry = EasyContactFormsClassLoader::getObject('CustomFormsEntries', TRUE, $id);
  2.         $content = $entry->get('Content');
  3.  
  4.         $xml = simplexml_load_string($content);
  5. /************************************************************************************************
  6.  *
  7.  * Added this section to load contact information into the contact since the plug-in doesn't do it by default
  8.  *
  9.  ***********************************************************************************************/
  10.       $load_user_info = array();
  11.       foreach($xml->div as $div) {
  12.          $id =  $div->attributes()->id;
  13.          
  14.          $fld = EasyContactFormsClassLoader::getObject('CustomFormFields', true, $id);
  15.          
  16.          $load = $fld->get('Settings');
  17.          $fxml = new EasyContactFormsSimpleXML($load);
  18.          $loadapp = (string) $fxml->LinkToAppField;
  19.          switch ($loadapp) {
  20.             case 'Users_Name':
  21.             case 'Users_Description':
  22.             case 'Users_email':
  23.                $load_user_info[str_replace('Users_', '', $loadapp)] = (string) $div->h1;
  24.                break;
  25.             default:
  26.          }
  27.       }
  28. /************************************************************************************************
  29.  *
  30.  * END: Added section to load contact information into the contact since the plug-in doesn't do it by default
  31.  *
  32.  ***********************************************************************************************/
  33.      
  34.         $userid = (string) $xml->attributes()->userid;
  35.         $userid = empty($userid) ? NULL : intval($userid);
  36.         if (empty($userid)) {
  37.             $users = EasyContactFormsClassLoader::getObject('Users');
  38.             $user = $users->getEmptyObject($newobjectmap);
  39.             $siteuserid = $entry->get('SiteUser');
  40.             $siteuserid = empty($siteuserid) ? NULL : $siteuserid;
  41.             if (!is_null($siteuserid)) {
  42.  
  43.                 $usrquery = "SELECT
  44.                             user_login AS username,
  45.                             user_email AS email,
  46.                             display_name AS name
  47.                         FROM
  48.                             #wp__users
  49.                         WHERE
  50.                             ID='$siteuserid'";
  51.  
  52.                 $susr = EasyContactFormsDB::getObjects($usrquery);
  53.                 $susr = $susr[0];
  54.                 $susrname = !empty($susr->name) ? $susr->name : $susr->username;
  55.                 if (empty($susrname)) {
  56.                     $user->set('Description', $susrname);
  57.                 }
  58.                 if (empty($susr->email)) {
  59.                     $user->set('email', $susr->email);
  60.                 }
  61.                 $user->set('CMSId', $siteuserid);
  62.             } else {   //added Else statment here to set the contact information being gathered, with the three lines below.
  63.             foreach($load_user_info as $kluo=>$luo) {
  64.                $user->set($kluo, $luo);
  65.             }
  66.          }     //end of added Else statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement