Manage how profile information is ordered?
wentsch - July 1, 2009 - 10:34
| Project: | User registration notification |
| Version: | 6.x-1.10 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hey there,
I've been using user register notification for a while and have always wondered if there might be a way of organzing the information that is being sent better.
I have quite a lot of profile information (in different categories) that I want to be sent, but those profile fields seem to get mixed up and are not displayed in the correct order I set up in the profile itself. Also, it would be great to put in some line breaks between profile information that belongs to different profile categories, just to get a better readable message.
I don't know where to start and appreciate any help.
regards,
daniel

#1
Am I getting it right, that I'll have to look around line 120 of user_regiter_notify.module? There goes the sql query:
$result = db_query('SELECT f.title, f.type, v.value FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE uid = %d', $uaccount->uid);
Gonna look into the db if I find anything I could order it after. Implementing line breaks between profile fields of different categories seem to be tough though :(
#2
You hit on the one thing I have been wanting to do but havn't had a change to yet. The plan is to allow profile_var and allow you to control how the data is displayed inside the email itself.
So you could layout the email anyway you wanted to.
Thanks
Robert
#3
Hey Robert,
I'm glad you've already been thinking about this – an admin option to build the profile data ordered would be awesome.
For now I simply added an "ORDER BY category DESC" statement to the query, so my pieces of profile info stay somehow connected inside the mail. Now I'm still thinking about how to put one more line break for every time information of a new category starts. I'll post if I'm successful.
regards,
Daniel
#4
As I said I need to add some code to break out the groups. You could add category to the return array and then check when
// at the top
old_category="";
// Inside the field loop
if ($field->category != old_category) {
old_category = $field->category;
$profile_data .= "\n\n";
}
#5
Added Profile options in the CVS. Next release 6.x-1.11 will include !profile_xxx and that will convert to the individual profile items.
Attach is a snapshot of that for you to test. I forgot to make a patch before I uploaded so here is the modified .module file. Simple save this file as a replacement to your current .module file.
Thanks
Robert
#6
#7
Thanks a lot.
Unfortunately I didn't manage getting it done.
If I replace the module with your attached file I don't regognize any change at all.
Then tried appying the snippet you posted above, which results in having 3 line breaks between every item, also when they're in the same category. What I did looks as follows, maybe I misunserstood something?
- adding category to the returned result (works, checked)
- setting $category to no value outside whe while loop
- adding a double line break to $profile_data if the returned category value is not equal to the one set before
- setting the value of $category to the one that come from the database
<?php
if (module_exists('profile')) {
$result = db_query('SELECT f.title, f.type, f.category, v.value FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE uid = %d ORDER BY category DESC', $uaccount->uid);
$old_category="";
while ($field = db_fetch_object($result)) {
if ($field->category != old_category) {
$old_category = $field->category;
$profile_data .= "\n\n";
}
switch ($field->type) {
case 'date':
$date_field = unserialize($field->value);
if (is_array($date_field)) {
$date_timestamp = mktime(0, 0, 0, $date_field['month'], $date_field['day'], $date_field['year']);
$profile_data .= sprintf("%s: %s \n", $field->title, format_date($date_timestamp));
}
break;
case 'checkbox':
if ($field->value)
$profile_data .= sprintf("%s: JA! \n", $field->title);
else
$profile_data .= sprintf("%s: NEIN! \n", $field->title);
break;
default:
$profile_data .= sprintf("%s: %s \n", $field->title, $field->value);
} // endswitch
} // endwhile
}
?>
#8
wentsch,
Easier Fix upgrade to 6.x-1.11 and use !profile_variable_name in the format you want.
Thanks
Robert
#9
Automatically closed -- issue fixed for 2 weeks with no activity.