Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Recording a boolean preference from the Application Form
dan39
New
It would be very helpful if someone could write an add-on that adds a checkbox for saving a Yes/No (or 0,1) boolean preference (such as a newsletter subscription, or a "do not send me offers via email" preference) into the application form. The user would also be able to update that preference from their account page.
The add-on wouldn't need to do anything more than that since anyone with admin access to the database can easily export the recorded data in nearly any format directly from their database manager (phpMyAdmin, etc.).
A more advanced version of this proposed add-on would let admins define multiple boolean preferences that can be placed in the database from the admin form (for example "please enter me in this month's sweepstakes")
I know that the "Predefined Attributes" can do this, but it's code is very outdated (it was written for Vanilla 0.9.2) and isn't being maintained anymore. Plus, it crams all of the labels and values into an array in the database, which is really not useful for simple boolean preferences that often need to be extracted and referenced easily. Additionally, it's companion add-on (User Export) to access that data no longer works in the latest release of Vanilla.
Is anyone aware of a more recent add-on that does something similar to this that can achieve this with some modifications?
Any solutions would be greatly appreciated. I would think that many people could find an add-on like this useful.
The add-on wouldn't need to do anything more than that since anyone with admin access to the database can easily export the recorded data in nearly any format directly from their database manager (phpMyAdmin, etc.).
A more advanced version of this proposed add-on would let admins define multiple boolean preferences that can be placed in the database from the admin form (for example "please enter me in this month's sweepstakes")
I know that the "Predefined Attributes" can do this, but it's code is very outdated (it was written for Vanilla 0.9.2) and isn't being maintained anymore. Plus, it crams all of the labels and values into an array in the database, which is really not useful for simple boolean preferences that often need to be extracted and referenced easily. Additionally, it's companion add-on (User Export) to access that data no longer works in the latest release of Vanilla.
Is anyone aware of a more recent add-on that does something similar to this that can achieve this with some modifications?
Any solutions would be greatly appreciated. I would think that many people could find an add-on like this useful.
0
This discussion has been closed.
Comments
As I said before, Predefined Attributes has a companion add on called "User Export" which allows you to export the survey-type array/data into a CSV file. But "User Export" only works in Vanilla 0.9.2. So, the recorded Predefined Attributes data is essentially useless — or at the very least, quite difficult to work with.
"User Export" probably only needs some minor tweaks (it seems to just be using some deprecated code) but I can't wrap my head around it to bring it up to compatibility with Vanilla 1.0.
I'm sure it's an easy fix, but I'm not having any luck.
So far I've added the code to a delegate that includes the tickbox on the registration form but I can't see how to include the data passed into the user creation SQLBuilder. The line I've been looking at is the last one in the code below, which would be triggered by a "User Manager / PreDataInsert" delegate:
$SqlBuilder = &$UserManager->DelegateParameters["SqlBuilder"]; $User = &$UserManager->DelegateParameters["User"]; $SqlBuilder->AddFieldNameValue("MyCustomPref", FormatStringForDatabaseInput($User->MyCustomPref));
but that won't work as rather than a field called 'MyCustomPref', in the latest Vanilla, the preferences are stored in a single field called "preferences" something similar to this:
a:3:{s:18:"MyCustomPref";i:1;}
The only documentation i can find with regards to updating a preference seems based on the logged in user:
$UserManager->SwitchUserPreference('MyCustomPref', $Switch);
How can I port that UserPreference function into something that'll work in the SqlBuilder bit above at user registration? Is the preferences field blank by default, therefore could that SqlBuilder line work like this?
$SqlBuilder->AddFieldNameValue("Preferences", FormatStringForDatabaseInput("a:3:{s:18:"MyCustomPref";i:1;}"));
Would there be any side effects to writing that in? And what do the "a:3" and "s:18" bits represent?
Anyone know the right way of going about this?