associate special data with each user
4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 27, 2010 (RSS)
By moh3 - August 27, 2010
i have a question about the member ship addon
i would like to associate special data specific for one user
for example i would like to show that user data related to him,like a phone bill how would i able to do such a thing
Re: [moh3] associate special data with each user
By Chris - August 27, 2010
You can do this using a List Field. Let's say you have a Multi Record section called "Phone Bills", add a List Field to it called "user":
Field Label: User
Field Name: user
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: username
Now you can associate Phone Bills with Accounts.
Finally, to show a user their Phone Bills, you'll want to use a 'where' clause to get only the records associated with the CURRENT_USER's num:
list($phone_billsRecords, $phone_billsMetaData) = getRecords(array(
'tableName' => 'phone_bills',
'where' => mysql_escapef('user = ?', $CURRENT_USER['num']),
));
Does that help? Please let me know if you have any questions.
Chris
Re: [chris] associate special data with each user
By moh3 - August 27, 2010
can i use external data that i pull from a different database say i have a already built database that already has phone bills how can i integrate that data with the membership addon,i have one idea in my head is by using a normal mysql query but how can i join the two together to pull out data
Re: [moh3] associate special data with each user
By Chris - August 27, 2010
You'll likely want to use custom SQL to do this. How you join depends on what data is available. Take a look at the cms_accounts table to see what fields are there. I'm imagining that you'll probably want to use email, username, or first_name+middle_initial+last_name. Alternately, you could add a new field to your CMS Builder accounts table.
Chris