createdByUserNum when accounts in a different table
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: September 8, 2014 (RSS)
By ht1080z - September 2, 2014 - edited: September 3, 2014
Hi,
I use a different table ('members') for the members of my page while the base cms users is in the 'accounts' table.
When i insert a new user to the 'members' table from my front pages the createdByUserNum and updatedByUserNum from which table are selected? i have users with the same nums but with different permissions in this 2 tables as well.
I' am sure that users created from the cmsAdmin (logged in with user from account table) createdByUserNum and updatedByUserNum is from the account table.
Zero value for these fields are sustainable?
PS: In the membership plugin code generator (signup), the default variable for these are $CURRENT_USER['num'], that i think is wrong because there is no $CURRENT_USER before login.
Please advise,
Karls
Hi Karls,
Thanks for bringing this to our attention. The value for createdByUserNum and updatedByUserNum should actually be 0, as the CURRENT_USER values won't be set until the user has logged in. Here is the change you need to make:
//
$colsToValues = array();
$colsToValues['createdDate='] = 'NOW()';
$colsToValues['updatedDate='] = 'NOW()';
$colsToValues['createdByUserNum'] = 0;
$colsToValues['updatedByUserNum'] = 0;
// fields defined by form:
//$colsToValues['agree_tos'] = $_REQUEST['agree_tos'];
$colsToValues['fullname'] = $_REQUEST['fullname'];
$colsToValues['email'] = $_REQUEST['email'];
$colsToValues['username'] = coalesce( @$_REQUEST['username'], $_REQUEST['email'] ); // email is saved as username if usernames not supported
$colsToValues['password'] = $passwordHash;
// ... add more form fields here by copying the above line!
$userNum = mysql_insert(accountsTable(), $colsToValues, true);
We've updated our development copy of the plugin with this change, and it will be in the next release.
The values that are stored in these fields are normally the num values from the accounts table that last updated/created the record. But they're not required fields, so if you want to store num values from different tables in them you can.
Cheers,
Greg
PHP Programmer - interactivetools.com