Re: [mgobey] Site membership plugin
Hi Michael,
I think you're on the right track. I would add a `type` List Field to the `accounts` table so that you'll know whether you've got a "Job Seeker" or "Employer" account immediately. Your `job_seeker_profile` and `employer_profile` tables can be Multi Record sections in CMS Builder - you'll just need to add a List Field to reference the correct account:
Field Label: Account
Field Name: account
Field Type: list
Display As: pulldown
List Options: Get options from database (advanced)
Section Tablename: accounts
Use this field for option values: num
Use this field for option labels: fullname
Then, on front end pages, you can get the associated record like this:
<?php
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
if ($CURRENT_USER['type'] == "Job Seeker") {
list($job_seeker_profileRecords, ) = getRecords(array(
'tableName' => 'job_seeker_profile',
'where' => 'num = ' . mysql_escape($CURRENT_USER['num']),
'allowSearch' => false,
));
$job_seeker_profile = @$job_seeker_profileRecords[0]; // get first record
if (!$job_seeker_profile) { die("Couldn't find job_seeker_profile!"); }
echo "Hello Job Seeker!";
showme($employer_profile);
exit();
}
elseif ($CURRENT_USER['type'] == "Employer") {
list($employer_profileRecords, ) = getRecords(array(
'tableName' => 'employer_profile',
'where' => 'num = ' . mysql_escape($CURRENT_USER['num']),
'allowSearch' => false,
));
$employer_profile = @$employer_profileRecords[0]; // get first record
if (!$employer_profile) { die("Couldn't find employer_profile!"); }
echo "Hello Employer!";
showme($employer_profile);
exit();
}
else {
die("invalid account type");
}
?>
What we really need to understand is how we can copy the num value to relevant table and display and edit it through the Site membership plug-in.
In the sample_signup.php script that comes with the Website Membership plugin, the `num` field is gotten after the INSERT via this code:
$userNum = mysql_insert_id();
If you want to create the associated `job_seeker_profile` record then, you'll use that value to reference the `account` record you just created.
Does that help? Please let me know if you have any questions.
All the best,
Chris