Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Check users permissions and hide content based on it?Check users permissions and hide content based on it?
Previous
 
Next
New Post
12/9/2009 2:34 AM
 

Hi all, I have what I thought would be a simple thing to do but is proving to be exceedingly difficult to find any useful information on.  My needs are simple, I have a module I am developing in which I need to hide/show a few controls (not dnn controls, .net controls like labels). I do not need any fancy custom permissions, and will be fine with just the built in EDIT / VIEW permissions.

The problem is that I have absolutely no idea how to actually check if the current user has (or doesn't have) EDIT permission for this module.

There are a few articles about building custom permissions, but this is not what I want and way over the top. All I need to do is show/hide a label or two based on whether the current user has the EDIT permission.  

I think I should be using the HasModuleAccess() method, but the documentation for this method sucks, and doesn't seem to tell me anywhere how to use it or what the arguments are for....not to mention that I can't find an example.

Anyone have a simple example somewhere?

Thanks in advance.

 
New Post
12/9/2009 6:35 PM
 

Here is how to check to see if user has a certain role.

if (DotNetNuke.Security.PortalSecurity.IsInRoles("Administrators"))

There is also a method HasEditPermissions in there, but I haven't used it.    I am sure you will figure it out with this though.

 
New Post
12/9/2009 6:39 PM
 

Thanks! I just couldn't find that!  Got it working now though.

 
New Post
1/7/2011 12:28 PM
 
I wanted to add to this post. Here is how I was able to display content in a custom module based on a user having Edit permissions even if they were not an administrator:

<%  If DotNetNuke.Security.Permissions.ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Edit, "EDIT", ModuleConfiguration) Then%> 
<a target="_blank" class="CommandButton" href="/EventControl.aspx"><img src="/images/edit.gif" />Add To/Edit this event list</a>
<%  End If%> 

JF Logomark

Kurt Meredith

Web Developer
Johnson Ferry Baptist Church
Marietta, Georgia

www.johnsonferry.org

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Check users permissions and hide content based on it?Check users permissions and hide content based on it?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out