- Posts: 22
COMMUNITY FORUM
k2 extra fields visibility for specified user id
- Vlachos Evaggelos
-
Topic Author
- Offline
- Junior Member
Less
More
9 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'): ?>
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 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
Please Log in or Create an account to join the conversation.
- Vlachos Evaggelos
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
9 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?
<?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
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
9 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
<?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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 6 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:
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))
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))
Please Log in or Create an account to join the conversation.