Easy to update User Attributes using this add-on?

Permalink Browser Info Environment
I haven't bought this add-on yet, but I noticed that it has two features I needed: 1) Ability to capture logged-in users 2) and ability to report results in Dashboard.

There's a third function I need which I mentioned here:

http://www.concrete5.org/community/forums/customizing_c5/form-input...

It's basically just an extended form and controller that allows User Attributes to be updated/added upon submission. Thing is, I need some of the features of this add-on too.

Would I be able to update user attributes with this addon? Or at least create a template and extend the controller to have this third functionality possible?

Type: Discussion
Status: New
edenxavier
View Replies:
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi,

You are on the right track already according the discussion you posted.

You could change the controller.php in the block and add your wanted code.

Check the function action_submit_form. There all the data is processed. You should be able to add your code there.

Hope you figure it out!

Regards,

Corretje

Note: Sorry for the delay, due to vacation and work I wasn't able to work on the support requests.
edenxavier replied on at Permalink Reply
edenxavier
Yep, I'm tinkering with it right now. Actually I'm still looking over the action_submit_form function and while I can guess where to stick the code in, I'm having difficulty trying to pull the post data to set certain attributes since input field IDs don't have a specific name that's hardcoded in the default template, if that makes sense. So thus I have no real lead on how to "refer" to a form field's ID. Ugh. So I tried doing:

$u = new User();
$ui = $ui = UserInfo::getByID($u->getUserID());
$ui->setAttribute("purchase_date", $_POST['Question4']);


but that's not doing anything.
edenxavier replied on at Permalink Reply
edenxavier
Nevermind, I actually figured it out. But I think it's a crude way of doing it since I had to use Firebug to find out what the field names were so I can refer to them. I'll post the code later on.
DeWebmakers replied on at Permalink Reply
DeWebmakers
Messy but working! I like it :)

You right about the code. The formfields aren't named as your would name a "normal" form. They all have ID's or numbers.

I'm looking forward to the code. Maybe we can use it in a newer version.

Regards,

Corretje
edenxavier replied on at Permalink Reply
edenxavier
Yep, it got the job done. :) I'm sure you can turn it into something more elegant.

function action_submit_form_() { 
$ip = Loader::helper('validation/ip');
Loader::library("file/importer");
$modelname = $_POST['Question7'];
$productno = $_POST['Question8'];
$sellername = $_POST['Question9'];
$purchasedate = $_POST['Question10'];
$u = new User();
$ui = $ui = UserInfo::getByID($u->getUserID());
$ui->setAttribute("model_name",$modelname);
$ui->setAttribute("product_no",$productno);
$ui->setAttribute("seller_name",$sellername);
$ui->setAttribute("purchase_date",$purchasedate);
DeWebmakers replied on at Permalink Reply
DeWebmakers
Great! Thanks.

We should make a connection between a question and an attribute. Maybe we should make it possible to select user attributes, that should fix the whole connection between fields thing...

Thanks again!
edenxavier replied on at Permalink Reply
edenxavier
Most definitely. I can imagine more practical uses for associating certain inputs with user attributes. The client that needed this wanted to use your form for product registrations, and then autoupdate a user's attributes so they know who registered it. This is helpful for them especially when a user needs to request a repair in the future: when a user submits a repair request, we just look them up and see what product they have.
DeWebmakers replied on at Permalink Reply
DeWebmakers
I know what you mean.

Couldn't it be done with the basic registration form of C5? The biggest problem then is when a customer has more than one product....
edenxavier replied on at Permalink Reply
edenxavier
Yes it could definitely be done with the regular registration form. But we've decided that sometimes customers will still register and participate on the site even when they don't own the client's products, so we needed to provide a second way just in case.

Ah, seems you've touched on a new problem I'm having. Yes, multiple product registrations is a new issue. We've agreed that realistically there'd be a limit a customer would register. We're still figuring out the logistics though.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.