Hide content for specific roles

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
2/11/2012 4:05:46 AM
Nux
Gravatar
Total Posts 183

Hide content for specific roles

Hi there,

long time that I have been here Embarassed, but I have a small question.
Is there a way that a content block can be hidden for specific roles?
I have a page, where users can download a pdf. But the pdf download is only for specific users.
People who would like to download the pdf, have to fill in a form (created with the magnific form wizard) and the admin of the site put those people to the specific role. But I would like to have a page with and the form and the link to the pdf, but showing the form to the authenticated users which are not in the group, and hiding the form when they are in the role.
As I can see, i can setup the download content that only the users of the role can view the link, but I don't know how to hide the form for those users.

Is there a way to do this?
Or is this a Feature Request?

Thx for the help!

2/11/2012 12:17:55 PM
Gravatar
Total Posts 2202

Re: Hide content for specific roles

Hi,

Just so I know I have understood your question properly, you want to show a form to all authenticated users who do not belong to a specific group, is that correct? 

You could create a role for all users that should see the form and then set that role in the "Roles that can view this content" security setting for the form. You would remove the "All Users" and "Authenticated Users" from that setting as well. Then, you would create another role for all users that should see the downloads and set that role in the "Roles that can view this content" security setting for the content containing the downloads (preferrably using the Shared Files module because it is secure). The admin would have to manually remove users from the first role and add them to the second after they've completed the form, unless you write a Form Submission Handler to do that for you. You would also need to add all of the correct users to the role for viewing the form.

HTH,
Joe 

2/11/2012 2:00:03 PM
Nux
Gravatar
Total Posts 183

Re: Hide content for specific roles

You are correct. But to be honest, I found it strange that nobody has ever got the question.

Setting the view permission, but not hiding.
Anyway, in your solution, we should manually put every new registered user in a role. And that is to much work.
So if there is nothing else, I think I need to program it?
I'm correct that there is a handler that I can use when someone register? I thought I read it somewhere, but where...

2/11/2012 4:22:41 PM
Gravatar
Total Posts 2202

Re: Hide content for specific roles

Hi,

You could use the User Registered Event Handler to place new users into specific roles.

For current users, you could write a simple SQL script to handle it.

HTH,
Joe D.

2/12/2012 2:39:06 AM
Nux
Gravatar
Total Posts 183

Re: Hide content for specific roles

Thanks Joe,

I will do that. Didn't do it before, but guess it is not that difficult.

Let you know when I have got it :)

2/12/2012 7:41:14 AM
Nux
Gravatar
Total Posts 183

Re: Hide content for specific roles

Well, just done the thing, quite easily ;).
The only thing that wasn't in the example code, was a reference to mojoPortal.Business.WebHelpers.UserRegisteredHandlers.

So those who doesn't understand, take the code and add
using mojoPortal.Business.WebHelpers.UserRegisteredHandlers; on the usings.

And that's it.

2/13/2012 12:41:44 PM
Gravatar
Total Posts 1204
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Hide content for specific roles

Just FYI, Joe Audette has said that he will be adding the functionality to automatically assign new users to a security role in a future version of mojoPortal.

Jamie

You must sign in to post in the forums. This thread is closed to new posts.