Create a log of member logins?
6 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: September 13, 2010 (RSS)
By zip222 - September 10, 2010
Re: [zip222] Create a log of member logins?
By Jason - September 10, 2010
If you're using the website Membership Plugin, you could add some code to the login function that writes a record to a table or to a file.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Create a log of member logins?
By zip222 - September 11, 2010
Re: [zip222] Create a log of member logins?
By Chris - September 12, 2010
Maybe I can help without sending you to consulting. If this doesn't work for you, please send in a request for a quote and we'll be happy to get back to you as soon as possible.
Create a Multi Record section called "Login Log". Modify it and remove all the fields except "num" and "createdDate" (note that you'll need to "Enable System Field Editing" under the "Advanced Commands..." dropdown to remove some of the fields.) Add a List Field called "Who". Modify your "Who" field as follows:
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, make some more changes to your Login Log section, this time at the top of the page:
In the General tab, change "ListPage Fields" to "createdDate, who". Under the Viewer Urls tab, change "Filename Fields" to "". Under the Searching tab, set "Search Fields" to "who, createdDate". Finally, under the Sorting tab, set "Order By" to "createdDate DESC". Now click Save Details.
Now open up cmsAdmin/plugins/websiteMembership/websiteMembership.php in a text editor and find "redirect on success". Add the code in red before "redirect on success":
// CUSTOM CODE! add record to login_log
global $TABLE_PREFIX;
mysql_query(mysql_escapef("INSERT INTO {$TABLE_PREFIX}login_log SET createdDate = NOW(), who = ?", $CURRENT_USER['num']))
or die("Mysql error adding login_log record: ". htmlspecialchars(mysql_error()) . "\n");
// redirect on success
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Create a log of member logins?
By zip222 - September 13, 2010
Slightly related question:
In your instructions you specify that the membership plugin is inside of a folder called "websiteMembership/" - is it a problem if my is not? The php file is just placed in the plugins folder.
Re: [zip222] Create a log of member logins?
By Jason - September 13, 2010
Glad to hear you got that working. The plugin doesn't have to be in that folder. As long as it's somewhere inside the plugins folder and has been activated, you should be fine.
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/