View Full Version : Using phrases in user profile fields
JoergZ
10-20-2005, 10:00 PM
Short Description
Unfortunately it is not possible in the standard-vB to use phrases in user profile fields. If you have only one language installed, this is no problem. But if you have more than one language on your board, this is bad.
With this hack, you can use phrases for user profile field title, description and select-options.
So you will have in the UserCP, in the meber-search and in the profile-view the text for user profile fields multilanguage. (See screenshots)
Though the main part of this hack is packed into a product, it is necessary to make some code-modifications, because there are new hooks necessary.
Requirements
vB 3.5 (Tested up to 3.5.1)
Installation-Time
approx. 15 - 20 minutes
Changes
Code-Modifications: 4
Template-Modifications: 3
New files: 1
Support
I have not marked the box "supported" because I am not always available and can answer in short time, but of course I will try helping you, if there are problems.
Open issues
When you get as administrator a mail, that a new user has registrated, in this mail, the phrase-converting is not implemented yet.
Updates
21.10.05: I have updated the hack. Now the phrases for the profile fields are shon correct on the registration page and in the AdminCP, when you add or search there a user. The ZIP-file contains a install-description for the new version, and a update-description, if you had already installed version 1.0
01.11.05: Update to 1.1.1: Bugfix for selection-options. They were interpreted always as phrase, even if you entered them as fix text. For updating only import the product and choose "Allow Overwrite" yes.
NOTE !!!
I marked "is in beta-stage" because I want to have first a feedback of some people, if this hack works on their board correct. Of course I have tested it on my installation, but you know, strange things can happen. When some people use this hack without problems, I will remove the beta-stage.
Please click https://vborg.vbsupport.ru/ (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=98904) if you have installed this hack, to get informations, if there are upadtes or corrections.
nexialys
10-21-2005, 01:16 AM
great idea... i don't like single-language features...
Andreas
10-21-2005, 03:23 AM
I think you can get rid of the file edit of class_dm_user.php:
The Return value of set_userfields seems to be only used in register.php, where it is accessible in Hook register_addmember_process before it is used in prhase newuser to inform moderators about the new user.
You must do the replacement there, as otherwise you could catch the wrong phrase anyway, as the moderators might use other languages than the user who is registering.
JoergZ
10-21-2005, 07:00 AM
@Andreas: Thanks for the hint. But the change in class_dm_user.php I made, to get the correct error-message. Otherwise the error-message would say e.g. You may only select 1 option(s) for the $title_checkboxtest field. I looked a lot around, but I did not found another point to replace the field-title with the text from phrase.
Moreover I forgot two things: The register-page and the AdminCP (If you add a user or search a user in the AdminCP. The phrases are not tranlated there.
I will add this, and publish an update on weekend.
J?rg
derfelix
03-22-2006, 05:05 PM
well i just found another one..
in memberlist when you display the profilefields.. it shows the strings..
example in attachment...
but it works great in profile...
Felix
JoergZ
03-22-2006, 05:09 PM
O.k., thanks for the hint. I don't know yet, if I will publish an official update, due to the low interest to the mod.
But I will have a look, and maybe can give a hint, how it can be fixed for the memberlist.
Best regards
Jörg
derfelix
03-22-2006, 05:11 PM
thx..
i think its great..specially for multilingual boards.. where the profile is important...
Felix
JoergZ
03-22-2006, 09:09 PM
specially for multilingual boards.. where the profile is important...
That's the reason, why I made it.. :)
Concerning your problem: I have checked it, and it should work.. It works fine on my board, I only forgot, that I use it also in the memberlist :D
Please check via your AdminCP, if the plugin for the hook memberlist_fetch_prffld_hack exists and check, that you made the change in the memberlist.php
Which vB-version are you using ? I have not tested it on the latest 3.5.4 version.
If it is still not working for you, I will make on the weekend a test-installaton on a clean, new vB installation and check it.
Best Regards
J?rg
derfelix
03-23-2006, 03:30 AM
very strange..
its not working..
just checked.. everything is there..
the hook, the plugin... hmmm
i'm running 3.54
before you go into trouble.. i'll check this afternoon.. (my own little debug system.. ;) ) just to see what variables are passed..
I assume there is a collision with another hack.. but.. i couldnt imagine with wich.. hmmm
Felix
derfelix
03-23-2006, 01:20 PM
Ok I looked into it..
And.. there is good and bad news...
First the good news:
on 3.54 board.. your hack does exactly what you told it to..
and that part works perfectly.. You can even search the memberlist with the text of the phrases in the advanced member search!!!! which I think is great!!!
But and that is the bad news:
The new hook in the memberlist is ONLY affecting the search...
it is within the // advanced search
if ($_REQUEST['do'] == 'search')
{
section...
The simple display (output of the memberlist) is above!!!!
and there, there is no hook..
but as I see it.. its more complicated.. than I thought because the title and the stored field content are replaced at different locations..
But again.. I only have 3.54 ... maybe it was different before...
Felix
JoergZ
03-23-2006, 01:38 PM
Hello Felix !
You are right, sorry. I have "cheated" in my board. I have in the memberlist a field "country", but it shows a flag. And the header comes not from the profile-field, I modified the template and use a phrase. :D
but as I see it.. its more complicated.. than I thought because the title and the stored field content are replaced at different locations..
Maybe that's the reason, why it is not included yet ... :D
But I will have a look at the problem and if I have a solution, either release a new version or give the instruction how to have the fields in the memberlist. (But maybe I have no time before the weekend for this, so you have to wait 2 or 3 days).
Best regards
J?rg
derfelix
03-23-2006, 02:13 PM
Thanx... guess what..
I got it working for me... :banana:
It was a little tricky though :rolleyes:
And as I am a newbie to vbulletin (used to hack only phpbb boards) i could never put this into a plugin..
(and as there allready was a fileedit.. i think this will cost less ressources)
ATTENTION I only tested it with the multiple checkbox example in your file..
so what i did:
first find in memberlist.php
if ($value['type'] == 'checkbox' OR $value['type'] == 'select_multiple')
{
unset($customfield);
foreach ($value['data'] AS $key => $val)
{
if ($userinfo["$value[varname]"] & pow(2, $key))
{
$customfield .= iif($customfield, ', ') . $val;
}
}
}
else
{
$customfield = $userinfo["$value[varname]"];
}
and replace with:
// ########### Lang hack part one ---start ########
if ($value['type'] == 'checkbox' OR $value['type'] == 'select_multiple')
{
unset($customfield);
foreach ($value['data'] AS $key => $val)
{
if ($userinfo["$value[varname]"] & pow(2, $key))
{
$phraseprffld = '';
$testforphrase = substr(trim($val), 0, 1);
if ($testforphrase == '$')
{
$prffldphrase = substr(trim($val), 1);
$val = $vbphrase[$prffldphrase];
}
$customfield .= iif($customfield, ', ') . $val;
}
}
}
else
{
$phraseprffld = '';
$testforphrase = substr(trim($userinfo["$value[varname]"]), 0, 1);
if ($testforphrase == '$')
{
$prffldphrase = substr(trim($userinfo["$value[varname]"]), 1);
$customfield = $vbphrase[$prffldphrase];
}
else
{
$customfield = $userinfo["$value[varname]"];
}
}
// ########### Lang hack part one ---end ########
then find:
$customfield = $customfield['title'];
and ABOVE add:
// ########### Lang hack part two ---start ########
$testforphrase = substr($customfield['title'], 0, 1);
if ($testforphrase == '$')
{
$prffldtitle = substr($customfield['title'], 1);
$customfield['title'] = $vbphrase[$prffldtitle];
}
// ########### Lang hack part two ---end ########
Well for me it seems to work!!!!
Felix
Does this hack work with 3.6.7?
Unfortunately it didn't work for me:
I could see the check boxes in edit profile but when saving it gives this error:
Parse error: syntax error, unexpected T_GLOBAL, expecting '{' in /home/xxxxxxx/public_html/forums/includes/class_dm_user.php on line 972
when trying to access the member list it gives this error:
Parse error: syntax error, unexpected T_ELSE in /home/xxxxxxx/public_html/forums/memberlist.php on line 898
I didn't try derfelix's modification...
But the idea is great and useful! :)
KubisForce
08-10-2008, 12:51 PM
Is there a newer version or does it work with vb 3.7?
JoergZ
08-10-2008, 01:10 PM
I have not installed it on 3.7, but I doubt it will work. Sorry, there is no newer version. And I currently don't have time to work on a version for 3.7.
Br
Joerg
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.