Keyword

k2 extra fields visibility for specified user id

  • Vlachos Evaggelos
  • Vlachos Evaggelos's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 7 months ago #148013 by Vlachos Evaggelos
k2 extra fields visibility for specified user id was created by Vlachos Evaggelos
Hi, i want in a k2 category to enable the visibility of extra fields but for one register user id, not for all.
In public_html/templates/template_name/html/com_k2/templates/default/item.php line 191 edit the if code but the extra fields can view for everyone.
Add the code && $user->id = '543' but dont work, and all visitors can views the extra fields.
Any idea??

Thanks for your time.

<?php if($params->get('itemExtraFields') && count($this->item->extra_fields) && $user->id = '543'): ?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #148016 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 extra fields visibility for specified user id
Did you assign $user to Joomla!'s user object? docs.joomla.org/Accessing_the_current_user_object

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Vlachos Evaggelos
  • Vlachos Evaggelos's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 7 months ago #148038 by Vlachos Evaggelos
Replied by Vlachos Evaggelos on topic k2 extra fields visibility for specified user id
Yes i assign $user to Joomla!'s user object

<?php $user = JFactory::getUser(); ?>
<?php if($params->get('itemExtraFields') && count($this->item->extra_fields) && $user->id = '543'): ?>

With this method again dont work

<?php $user = JFactory::getUser(); if($params->get('itemExtraFields') && count($this->item->extra_fields) && $user->id = '543'): ?>

$user->id code work because echo variable and see the login user id. The problem is in this code $user->id = '543'. Any idea?

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

  • Vlachos Evaggelos
  • Vlachos Evaggelos's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 7 months ago #148039 by Vlachos Evaggelos
Replied by Vlachos Evaggelos on topic k2 extra fields visibility for specified user id
Work with this

<?php $user = JFactory::getUser(); if($params->get('itemExtraFields') && count($this->item->extra_fields) && $user->id == '543'): ?>

If i want group this code get group id?? $user->gid == '8' ??

Thanks for your time

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #148058 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 extra fields visibility for specified user id
As per the instructions in Joomla!'s documentation:

Use $user->groups to retrieve an array with all the IDs that refer to the groups (from #__usergroups table) of a user.


Then you can use PHP's in_array() function - php.net/manual/en/function.in-array.php - to look for the id in the array. eg: if (in_array( ID , $user->groups))

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum