latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Plotting custom data for members on graph

Home Forums Community Forum Plotting custom data for members on graph

This topic contains 8 replies, has 3 voices. Last updated by  Danie Ludick 4 years, 1 month ago.

Topic Author Topic
Posted: Wednesday Nov 28th, 2012 at 2:07 pm #32798

Goof day,

I am quite new to the forums here – and also to using S2Member Pro. What I would like to do is the following:
I want to facilitate a sequence of data for each of my users, e.g. monthly electricity usage, and plot this on a graph on his/her own profile page.

I am guessing the key components to this would be a MySQL database for each of the users where the data is inserted and a pretty decent plotting library that can extract this data from the database and plot it on a graph?

How would I go about doing this with S2Member?

Kind Regards,
Danie

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Wednesday Nov 28th, 2012 at 4:44 pm #32821
Raam Dev
Username: Raam
Staff Member

Hi Danie,

I’m not sure how you’re expecting to use s2Member here. The s2Member plugin is designed to restrict access to WordPress Posts and Pages. If you have a MySQL database for each user and you want to display graphs using data in that database, all of that would take place outside the s2Member plugin.

Posted: Thursday Nov 29th, 2012 at 12:14 am #32858

Good day,

Thank you for your reply. I understand what you mean, and as I said, I am quite new to using S2Memeber. Perhaps I should phrase my query differently:

If I have a number of external databases for each of my registered user, then how can I extract this information from them? When a user logs in, then he/she is directed to a custom profile type page. On that page, there is then some PHP code that connects to the correct database, based on the user-information. The data in this database can then be extracted and displayed. Will S2Member be able to provide the required functionality/info for me to select the correct external database for the user?

Kind Regards,
Danie

Posted: Thursday Nov 29th, 2012 at 12:37 am #32859

maybe this can be of help http://codex.wordpress.org/Function_Reference/get_user_meta and http://codex.wordpress.org/WPMU_Functions/get_current_user_id

  • This reply was modified 4 years, 1 month ago by  boudewijn lutgerink. Reason: added get_current_user_id
Posted: Thursday Nov 29th, 2012 at 12:49 am #32862

Thank you boudewijn!

I am starting to get the picture here – I hope :). Basically, the S2Member framework sits on top of the standard WordPress memebership structure. When a user is logged in, I can use standard WordPress functions, such as get_user_meta() to extract a unique ID for that user. This ID can then be used to connect to a different/external MySQL database where other data for the user is stored, e.g. monthly water-readings. When the data is extracted, plotting it on a graph is easy.

Does this all sound to be on the correct track?

Posted: Thursday Nov 29th, 2012 at 1:17 am #32869

spot on… ;-)

Posted: Thursday Nov 29th, 2012 at 1:26 am #32870

Thank you,

Perhaps it can be an option to store this information for each user directly in the standard WP-database – or, from a security/maintainability point of view, it might be better to use a separate database for this info.

I am not sure that this is the correct forum for this discussion?

Posted: Thursday Nov 29th, 2012 at 1:44 am #32871

Entering the subject of database design hey?
OK then. There is no need for a different database, you need another table.
FYI, a database is a big container where tables reside and all the meta info like relation between tables, indexes etc. In MySQL (AFAIK) tables can not stand on themselves.

I assume here that the type of info you want to store for each user is basically the same.
What I would do is create a table with as primary index the user ID from the user meta table that WP creates.
Once you have the user ID from the get_current_user_ID function you can then query your table for a record for that user and read the info you need.
I am not really familiar (yet) how to do that in PHP, but I have no doubt that this info can be found in a PHP manual.

Posted: Thursday Nov 29th, 2012 at 1:47 am #32872

Thank you boudewijn!

I will have a look at this and post some of the results here when I have them!

Viewing 8 replies - 1 through 8 (of 8 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.