associate special data with each user

By moh3 - August 27, 2010

hello to all,

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

Hi moh3,

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.
All the best,
Chris

Re: [moh3] associate special data with each user

By Chris - August 27, 2010

Hi moh3,

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.
All the best,
Chris