Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
associate special data with each user

 

 


moh3
User

Aug 27, 2010, 1:34 PM

Post #1 of 4 (5563 views)
Shortcut
associate special data with each user Can't Post

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


Chris
Staff / Moderator


Aug 27, 2010, 2:26 PM

Post #2 of 4 (5559 views)
Shortcut
Re: [moh3] associate special data with each user [In reply to] Can't Post

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":


Code
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:


Code
  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


moh3
User

Aug 27, 2010, 2:43 PM

Post #3 of 4 (5555 views)
Shortcut
Re: [chris] associate special data with each user [In reply to] Can't Post

hello chris ,thanks for your reply i have one more question
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


Chris
Staff / Moderator


Aug 27, 2010, 3:31 PM

Post #4 of 4 (5552 views)
Shortcut
Re: [moh3] associate special data with each user [In reply to] Can't Post

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.
Chris