[Skip to main content](#vessel-content)

#   Password protect category pages customisation

##

- **[dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")**
- [![dunxmax's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/9795-dunxmax "View dunxmax's Profile") Topic Author
- [ Offline](/forum/user/9795-dunxmax)

Less More

- Posts: 82
- Thank you received: 6
-
-
-
- [](http://www.aquamandesign.co.uk)
-

13 years 6 months ago [\#101761](#101761) by [dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")  *[Password protect category pages customisation](/forum/9-commercial-jobs/81241-password-protect-category-pages-customisation#101761 "Hi all,  I have been posting in another thread regarding a customisation of Hikashop. Xavier of Hikashop suggested I come here for my answer.  Here's the thread so far:  But to summarise, here's what I'm after:  I am setting up a shop that will sell photos taken at sports events.  Some of the photos will be of children, so I want to protect these from the general public as much as possible.  At each event where photographs are taken a passkey will be published. This will enable registered users to the site to access the selection of photos from that event. I know this is not a super secure way of protecting the photos, but I think at least it will provide some security.  So when the user gets to the site they will first have to register - then they will be given a list of events. When they click on their specific event they will have to enter the published passkey before they see the photos from that event. This will be a category within Hikashop.  In the previous thread, Xavier from Hikashop, gave me the following advice:  So I have added a custom field called &quot;passkey&quot;.  He then told me to add the following code:  And he told me to add it here:  I've done this, but got the following error:  Xavier said:  That's when he told me to post here, in the commercial jobs.  I am not a coder so I don't understand how to use the $app solution.  Can anybody help, please.  Regards  Duncan McFarlane")* was created by *[dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")*

Hi all,

I have been posting in another thread regarding a customisation of Hikashop. Xavier of Hikashop suggested I come here for my answer.

Here's the thread so far: [ ](http://www.hikashop.com/fr/forum/2-general-talk-about-hikashop/79732-password-protect-category-pages.html#101663)

But to summarise, here's what I'm after:

I am setting up a shop that will sell photos taken at sports events.

Some of the photos will be of children, so I want to protect these from the general public as much as possible.

At each event where photographs are taken a passkey will be published. This will enable registered users to the site to access the selection of photos from that event. I know this is not a super secure way of protecting the photos, but I think at least it will provide some security.

So when the user gets to the site they will first have to register - then they will be given a list of events. When they click on their specific event they will have to enter the published passkey before they see the photos from that event. This will be a category within Hikashop.

In the previous thread, Xavier from Hikashop, gave me the following advice:

> I think that you have to use the custom fields on the table category to set a password by category.
> Then edit the view which is listing the products, generally "product / listing\_img\_title" and in this view add a check for the password.

So I have added a custom field called "passkey".

He then told me to add the following code: Code:

if(!empty($this-&gt;element-&gt;passkey) &amp;&amp; $app-&gt;getUserState( HIKASHOP_COMPONENT.'.passkey') != $this-&gt;element-&gt;passkey){ // Display only a form to enter the passkey // &gt; when pressing submit, save the value in session, and reload the page. // To save in session, you can use: $app-&gt;setUserState( HIKASHOP_COMPONENT.'.passkey',JRequest::getVar('passkey','')); }elseif(empty($this-&gt;element-&gt;passkey) &#124;&#124; $app-&gt;getUserState( HIKASHOP_COMPONENT.'.passkey') == $this-&gt;element-&gt;passkey){ // Display the the code }

And he told me to add it here:

> Add it in the view "product / listing" before:
> if(($this-&gt;params-&gt;get('show\_image') &amp;&amp; !empty($this-&gt;element-&gt;file\_path))\|\| ($this-&gt;params-&gt;get('show\_description',!$this-&gt;module)&amp;&amp;!empty($this-&gt;element-&gt;category\_description))){

I've done this, but got the following error:

> "Fatal error: Call to a member function getUserState() on a non-object in mysite/templates/js\_memo/html/com\_hikashop/product/listing.php on line 117"

Xavier said:

> That's probably because $app is not declared, you can use '$app = JFactory::getApplication();'

That's when he told me to post here, in the commercial jobs.

I am not a coder so I don't understand how to use the $app solution.

Can anybody help, please.

Regards

Duncan McFarlane

---

DunxMax

The more we learn the less we know.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzktY29tbWVyY2lhbC1qb2JzLzgxMjQxLXBhc3N3b3JkLXByb3RlY3QtY2F0ZWdvcnktcGFnZXMtY3VzdG9taXNhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[glazweb](/forum/user/2408-glazweb "View glazweb's Profile")**
- [![glazweb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2408-glazweb "View glazweb's Profile")
- [ Offline](/forum/user/2408-glazweb)

Less More

- Posts: 33
- Thank you received: 0
-
-

13 years 1 month ago [\#127405](#127405) by [glazweb](/forum/user/2408-glazweb "View glazweb's Profile")  Replied by *[glazweb](/forum/user/2408-glazweb "View glazweb's Profile")* on topic *[Password protect category pages customisation](/forum/9-commercial-jobs/81241-password-protect-category-pages-customisation#127405 "Hi all,  I have been posting in another thread regarding a customisation of Hikashop. Xavier of Hikashop suggested I come here for my answer.  Here's the thread so far:  But to summarise, here's what I'm after:  I am setting up a shop that will sell photos taken at sports events.  Some of the photos will be of children, so I want to protect these from the general public as much as possible.  At each event where photographs are taken a passkey will be published. This will enable registered users to the site to access the selection of photos from that event. I know this is not a super secure way of protecting the photos, but I think at least it will provide some security.  So when the user gets to the site they will first have to register - then they will be given a list of events. When they click on their specific event they will have to enter the published passkey before they see the photos from that event. This will be a category within Hikashop.  In the previous thread, Xavier from Hikashop, gave me the following advice:  So I have added a custom field called &quot;passkey&quot;.  He then told me to add the following code:  And he told me to add it here:  I've done this, but got the following error:  Xavier said:  That's when he told me to post here, in the commercial jobs.  I am not a coder so I don't understand how to use the $app solution.  Can anybody help, please.  Regards  Duncan McFarlane")*

Hi Duncan.
I have the same needs, to protect categories and/or products with a password.
Did you find someone the solve the problem ?

Thank you.

Regards

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzktY29tbWVyY2lhbC1qb2JzLzgxMjQxLXBhc3N3b3JkLXByb3RlY3QtY2F0ZWdvcnktcGFnZXMtY3VzdG9taXNhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")**
- [![dunxmax's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/9795-dunxmax "View dunxmax's Profile") Topic Author
- [ Offline](/forum/user/9795-dunxmax)

Less More

- Posts: 82
- Thank you received: 6
-
-
-
- [](http://www.aquamandesign.co.uk)
-

13 years 1 month ago [\#127475](#127475) by [dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")  Replied by *[dunxmax](/forum/user/9795-dunxmax "View dunxmax's Profile")* on topic *[Password protect category pages customisation](/forum/9-commercial-jobs/81241-password-protect-category-pages-customisation#127475 "Hi all,  I have been posting in another thread regarding a customisation of Hikashop. Xavier of Hikashop suggested I come here for my answer.  Here's the thread so far:  But to summarise, here's what I'm after:  I am setting up a shop that will sell photos taken at sports events.  Some of the photos will be of children, so I want to protect these from the general public as much as possible.  At each event where photographs are taken a passkey will be published. This will enable registered users to the site to access the selection of photos from that event. I know this is not a super secure way of protecting the photos, but I think at least it will provide some security.  So when the user gets to the site they will first have to register - then they will be given a list of events. When they click on their specific event they will have to enter the published passkey before they see the photos from that event. This will be a category within Hikashop.  In the previous thread, Xavier from Hikashop, gave me the following advice:  So I have added a custom field called &quot;passkey&quot;.  He then told me to add the following code:  And he told me to add it here:  I've done this, but got the following error:  Xavier said:  That's when he told me to post here, in the commercial jobs.  I am not a coder so I don't understand how to use the $app solution.  Can anybody help, please.  Regards  Duncan McFarlane")*

Hi Gazweb,

Contact Xavier at Hikashop, he helped me through it in the end in his spare time. Works fine.

Duncan

---

DunxMax

The more we learn the less we know.

The following user(s) said Thank You: [glazweb](/forum/user/2408-glazweb "View glazweb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzktY29tbWVyY2lhbC1qb2JzLzgxMjQxLXBhc3N3b3JkLXByb3RlY3QtY2F0ZWdvcnktcGFnZXMtY3VzdG9taXNhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.047 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
