Keyword

restrict extra field not registred users

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 2 months ago #98492 by kolmao
Replied by kolmao on topic restrict extra field not registred users
It does not work, I'm afraid it is not possible

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

More
13 years 2 months ago #98493 by BBC
This one hides all fields depending if User is logged in, or not.

Try to work with it and make it work for one extra field. Maybe solution is to disable automatic listing od all fields then call tehm all one by one, and remove one special for Guests.

 

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

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 2 months ago #98494 by kolmao
Replied by kolmao on topic restrict extra field not registred users
@BBC Thanks for your help

 

I'm not sure how to do that

 

This is the loop code

 

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('Additional Info'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField):?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<br class="clr" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>

 

Where should I insert the code you posted?

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

More
13 years 2 months ago #98495 by BBC
Just wrap this (already in item.php):

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

 

With this "User" code.

 

But it is just for testing. It works. I used2 browsers, one logged, another not. One show fields for logged, one don´´t.

I cannot make it work for just one field. Mybe you will have better luck.

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

More
13 years 2 months ago #98496 by BBC
Don´t forget

<?php endif; ?>

when you test.

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

More
13 years 2 months ago #98497 by BBC
Because of that i said maybe is good idea to remove original part of code for fields and liste them one by one.

With this code above you can easy hide "div" and "class".

 

One extra filed = one div/class.

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

More
13 years 2 months ago #98498 by william white
Replied by william white on topic restrict extra field not registred users
Sorry i havent gotten back to you, i have been buzy at work. I have the code you want almost working and will post it when it is working.

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

More
13 years 2 months ago #98499 by william white
Replied by william white on topic restrict extra field not registred users
This will work

      <?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>      <!-- Item extra fields -->      <div class="k2ExtraFields">          <h3><?php echo JText::_('Additional Info'); ?></h3>          <ul>            <?php foreach ($this->item->extra_fields as $key=>$extraField):?>            <!-- insert code to test for registared and wether or not to skip here Replace HideField2 with name of your extra field--> <?php $user =& JFactory::getUser(); ?> <?php if($extraField->name == "HideField2" && $user->get('guest') ==1) { ?> <!-- prove it works - delete the text below after testing -->            field omitted            <?php  } else { ?>            <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">                <span class="k2ExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>                <span class="k2ExtraFieldsValue"><?php echo $extraField->value; ?></span>            </li>            <?php } ?>            <?php endforeach; ?>
Attachments:

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 2 months ago #98500 by kolmao
Replied by kolmao on topic restrict extra field not registred users
Great work Willian,

 

Now hides only the specified field.

Thank you very much, now everything is perfect.

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

More
13 years 2 months ago #98501 by BBC
Thanks. It will be usefull sometimes.

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


Powered by Kunena Forum