Use the new WS Groups to protect valuable content



Hire Us!Download Video(0)Comments

I am sure by now you know how to protect modules and blocks, even download using WS Groups. Well, WS Group also has another very impressive usuage. You can protect content within pages without requiring the entire module to be protected by a WS Group.

This tutorial will teach you how to accomplish this simple feat.

Steps :

1. First you will need the group ids for the WS Group you want to give access to your protected content. You will need to access your database for this step. New versions of the module will make this much easier. Go to phpmyadmin and select your nuke database. Click on nuke_ws_groups. Click browse and get the group_id for each group that you want to give access to the protected contents.

2. In this tutorial we will use two WS Groups ( apples{-1}, oranges{-2}). As you can see the negative numbers are the WS Group ids. We will also show examples how to protect a link and an image.
First example will will protect the following link so only members in the WS Groups apples will be able to get access.

The in_wsgroups function is used to protect content so we will change the above to the following:

Some things that should be noted in the above code. The global $user should be somewhere on your page. It does not have to be above the protect link but you need it on the page for the code to work correctly. The rest of the code is rather easy to understand. Basically you are checking if the user is a member of the "apples{-1}" group and if they are then they see the link, if not then they get a message notifying them that they do not have access.

3 This next step we will protect an image but only give access to the WS Groups "oranges{-2}". The following is our image that we will protect.

We will protect the image exactly as the first example, except this time we will use -2 instead.

Now let's say you want both "oranges" and "apples" to view the link. This can easily be accomplised by using the || (OR) option in php.

Notice the codes are almost exactly as the previously examples except that we changed the if(in_wsgroups($user, -1) || in_wsgroups($user, -2)): to also check if the user is a member of the second group.

That's it! As you can see protecting your content is very easy when using WS Groups. If you need more help, please visit our forums.

 

Hire Us!Download Video(0)Comments