Adding fields to a log of member logins

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 18, 2014   (RSS)

Hi All,

A while back, Chris offered a suggestion for creating a login log to work with the website membership plugin: http://www.interactivetools.com/forum/forum-posts.php?postNum=2206751

The code he suggested to insert and populate a record in a login_log section was:

// 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");

I'd like to be able to add more fields from the Accounts table to the log (like first and last name, member level, etc.) but can't seem to modify the code correctly to insert more than one field..

I've tried things like adding a list field like 'first' to the section, pulling the value from accounts 'num' field and the label from the 'first_name' field and then adding:

// CUSTOM CODE! add record to login_log
global $TABLE_PREFIX;
mysql_query(mysql_escapef("INSERT INTO {$TABLE_PREFIX}login_log SET createdDate = NOW(), who = ?, first =?", $CURRENT_USER['num']))
or die("Mysql error adding login_log record: ". htmlspecialchars(mysql_error()) . "\n")

But that didn't work.

Any suggestions for the proper code/syntax for this?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Thanks Claire,

I'll plug that in and report back.

It sure is easier to do things when you understand the language.

Best

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - September 18, 2014 - edited: September 18, 2014

Thank you Claire,

That worked perfectly! (I expected no less...)

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php