real name instead of username in Vote & Comment

  • Posts: 57
  • Thank you received: 1
10 years 1 week ago #179501

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5.14-1

hi

How do i show real name instead of username in Vote & Comment

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 1 week ago #179528

Hi,

If you want to change the label of the "username" field to "real name" on the comment form, you can edit the file "form" of the view "vote" via the menu Display>Views and change the code:

<?php echo JText::_('HIKA_USERNAME'); ?>:
to:
Real name:

Please Log in or Create an account to join the conversation.

  • Posts: 78
  • Thank you received: 5
  • Hikashop Business
2 years 11 months ago #337470

To update this for version 4.4.3....

The standard functionality seems to put the username in the vote_pseudo databse field in the table XX_hikashop_vote. I don't know of a setting that changes that, but let me know if I'm wrong, Nicolas.

Therefore, to change what is put in that field, this file needs to be adjusted: administrator/com_hikashop/classes/vote.php

Change:

$element->vote_pseudo = $user->username;

To
$element->vote_pseudo = $user->name;

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 11 months ago #337497

Hi,

Yes, that's a way to go about it. However, doing it like that means that you'll have to redo the change after each update.
An alternative would be to develop a plugin with the onBeforeVoteCreate event to force the vote_pseudo value before it's saved in the database.
A simpler approach would be to leave it as is and instead modify the vote / listing.php view file via the menu Display>Views to add the code:

if(!empty($elt->vote_user_id)) {
$userClass = hikashop_get('class.user');
$user = $userClass->get($elt->vote_user_id);
if(!empty($user->name))
 $elt->vote_pseudo = $user->name;
}
after the line:
foreach($this->elts as $elt) {
so that it can load dynamically the user's name from the user entry in the database on the comments listing on the frontend.

Last edit: 2 years 4 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 78
  • Thank you received: 5
  • Hikashop Business
2 years 11 months ago #337501

Thanks, Nicolas. I'm assuming that is referring to the table XX_hikashop_vote, and for my install, it is putting IP addresses in the vote_user_id field...

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 11 months ago #337525

Hi,

The IP is set in the vote_user_id column either if you create the vote/comment from the backend, or if you create it on the frontend as a guest (since there is no user account that can be attached)
In such cases, your question of having the name or username displayed doesn't make sense since there is no user account linked to the vote/comment to get the name or the username from.

Please Log in or Create an account to join the conversation.

  • Posts: 78
  • Thank you received: 5
  • Hikashop Business
2 years 11 months ago #337553

Ah, that makes sense. Thanks!

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum