[solved] Building aTutorial for FEU/SelfRegistration/CompanyDirectory

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
kendo451

[solved] Building aTutorial for FEU/SelfRegistration/CompanyDirectory

Post by kendo451 »

It seems many people post questions on how to use CompanyDirectory with FEU/SelfRegister so site members can edit their own company listing.  There isn't a complete tutorial post on how to do this, so I am trying to write a tutorial that takes you from A to Z all the steps to do it.

In order to do that I have to get my own working, and I could use some help on one thing.

Having setup FEU/CC/SelfRegister and CompanyDirectory, how do we create a new CompanyDirectory record for the newly registered user automatically?  I was thinking of using the username from FEU as the company_id in {CompanyDirectory}.

The question is, will this create a new entry, if the company_id doesn't exist?
{CompanyDirectory action='fe_edit' companyid=$ccuser->property('username')}

If not, is there a simple way to create a new CompanyDirectory record for a new SelfRegistered user, automatically - with no administrator interaction?
Last edited by kendo451 on Sat Jan 24, 2009 5:11 am, edited 1 time in total.
kendo451

Re: Building aTutorial for FEU/SelfRegistration/CompanyDirectory

Post by kendo451 »

The answer is no.

In order to create a new CD record, you have to create a UDT.

Below is a UDT I cobbled together using elements from the CompanyDirectory module that creations a new record and adds the CD id to an FEUsers field called "cid".

I named it create_cd_record, and it takes two mandatory parameters: userID and company_name.  In my case, the business name is also part of the FEU properties, so here is the tag use to create a new CD record and update FEUsers with the new cid that is created:

{create_cd_record uid=$ccuser->loggedin() company_name=$ccuser->property('bname')}

And here is the code for the User Defined Tag:

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty();
if( !isset($gCms) ) exit;

$config =& $gCms->GetConfig();
$db = &$gCms->db;

$feusers =& CMSModule::GetModuleInstance('FrontEndUsers');
if( !$feusers )
  {
    $error='Error: FrontEndUsers Module not found.';	
	return $error;
  }


$company_name = '';
if (isset($params['company_name']))
{
	$company_name = $params['company_name'];
}

if ($company_name != '')
	{
		$query = 'INSERT INTO '.cms_db_prefix().'module_compdir_companies (company_name, address, telephone, fax, contact_email, website, details, picture_location, logo_location, create_date, modified_date, status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)';
		$db->Execute($query, array($company_name, '', '', '', '', '', '', '', '', trim($db->DBTimeStamp(time()), "'"), trim($db->DBTimeStamp(time()), "'"), 'draft'));
		
		$cid = $db->Insert_ID();

		$result=$feusers->SetUserProperty('cid',$cid);
	
	}
	else
	{
		$error = 'Error: Parameter company_name is empty!';
		return $error;
	}

return;
Last edited by kendo451 on Sat Jan 24, 2009 5:10 am, edited 1 time in total.
Milan J.
New Member
New Member
Posts: 7
Joined: Tue Jan 13, 2009 5:44 pm

Re: [solved] Building aTutorial for FEU/SelfRegistration/Com

Post by Milan J. »

Hi,

this is the solution I've been looking for! Can you please let me know where exactly do I need to put the UDT?

I've placed it to User registration, but it doesn't work.

Thanks
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [solved] Building aTutorial for FEU/SelfRegistration/Com

Post by calguy1000 »

There is no need for a UDT or anything now. There is sufficient information in the CompanyDirectory module's help and settings to setup this type of an environment.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “Modules/Add-Ons”