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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Programmatically add user to role and menusProgrammatically add user to role and menus
Previous
 
Next
New Post
8/26/2008 2:27 PM
 

Hi there,

I developped a module on DNN 4.8.4 which at some point add the current logged in user to a group called "My Group". That works fine.

Now, I have a page that is visible only to users of "My Group". When I programmatically add the user to the role, even though I can access the page, I am not able to see it in the menu. I have to logout-login for the page to appear in the menu.

Does anybody have any idea how to solve this?

Thanks in advance

Nico

 
New Post
8/26/2008 5:15 PM
 

I think it's because the user's menu is cached to avoid hitting the database so much.

What you can do is programmatically log the person in. I have an example of this at:

http://www.adefwebserver.com/DotNetNukeHELP/Misc/AutoPortalLogin.htm

Basically it's:

UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, GetIPAddress(), true);



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
8/26/2008 9:07 PM
 

After adding the role to the user, you will need to additionally clear the user cache.  You can do this by a call to ClearUserCache.  it is inside the DotNetNuke.Common.Utilities namespace, I believe under the DataCache object.

If you can't find it, just drop me an e-mail to msellers@iowacomputergurus.com and I'll send off a code sample.


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
9/10/2008 4:26 PM
 

Mitch Sellers wrote

After adding the role to the user, you will need to additionally clear the user cache.  You can do this by a call to ClearUserCache.  it is inside the DotNetNuke.Common.Utilities namespace, I believe under the DataCache object.

If you can't find it, just drop me an e-mail to msellers@iowacomputergurus.com and I'll send off a code sample.

Mitch,

Do you know if this will work for getting rid of the delay that occurs when a user pays subscription through PayPal and is redirected back to the site?

Ex:  New user registers, and their 'Registered Users' account is created and they are logged into the site.  They are then automatically directed to PayPal to complete payment for subscription.  Once payment is received, they are added to the "Paid Members" role group (via DNN core PayPal handlers) which gives them access to the 'protected' areas of the site.  The only problem is that there is a 1-2 minute delay for the user cache to be erased before they can access the 'protected' area -- when they get back to the site, they are actually IN the "Paid Members" role group, but don't have access until their cache is updated.

I'm thinking that by throwing the "ClearUserCache" in the post-paypal handler, their info would be updated with the more current 'Paid Members' access.  Does the 'ClearUserCache' go deep enough to do this?  Does it log them out of the site?

Thanks,

CJ

 
New Post
1/3/2009 11:35 PM
 

Michael Washington wrote

Basically it's:

UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, GetIPAddress(), true);

Where does GetIPAddress() comes from? I'm getting an error - it's not recognized...

And how would I remove a user from a certain role? In other words Im looking for the opposite effect, user completes a survey and when it is submitted I need to remove the user from the role that allows the user to see the survey tab on the menu.

Thanks,

Val

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Programmatically add user to role and menusProgrammatically add user to role and menus


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