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

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...How to get individual user box from member directory module.How to get individual user box from member directory module.
Previous
 
Next
New Post
9/5/2012 11:48 PM
 

Hi,

I wonder there is a way to get individual user box from member directory module for putting it in another page?

I am using ASP.Net and C#. I just want to show information of user base on user ID. From user ID I will show a box that contain user information just like member directory module. So I support there is a good way to do it. I will show sample images that illustration my issue. I hope they will be clear enough.

-  Picture 1 show all user box from Member Directory Module

 

 -  Picture 2 show individual user box in other page base on user ID.

 

Best Regards,

Dung Tri

 
New Post
9/13/2012 10:47 PM
 

The best way to do this is modified by personal self. Using user Id, I can get all information of user and then construct a user box just like in directory module. Below are some code demonstrate my work, hope they can be helped.

//Get current loged user id
public int GetUserId()
    {
        try
        {
            UserInfo _currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
            return _currentUser.UserID;
        }
        catch
        {
            return -1;
        }
    } 

//Get all user roles base on user name
public string[] GetUserRoles(string userName)
    {
        try
        {
            return Roles.GetRolesForUser(userName);
        }
        catch
        {
            return null;
        }
    }

//Detect current loged user's role
public string DetectDNNUser()
    {
        var userInfo = UserController.GetCurrentUserInfo();
        if (userInfo.IsInRole("Administrators"))
        {
            return "Administrators";
        }
        else if (userInfo.IsInRole("Admin Group"))
        {
            return "Admin Group";
        }
        return "";
    } 

//Get user info base on user id
public UserInfo GetUserInfo(int userId)
    {
        PortalSettings portalSettings = new PortalSettings();
        int portalId = portalSettings.PortalId;
        DotNetNuke.Entities.Users.UserController oUserController = new DotNetNuke.Entities.Users.UserController();
        UserInfo userInfo = oUserController.GetUser(portalId, userId);
        return userInfo;
    }

Besides there is an easy way to do this, that is link user name to the ActiveFeed page. All user information and control goes here.

Eg: <a href='http://" + GetDefaultPortalAlias() + "/ActivityFeed/tabid/" + 60 + "/userId/" + UserId + "'>username</a>

 //Get default Portal Allias
public string GetDefaultPortalAlias()
    {
        try
        {
            PortalSettings portalSettings = new PortalSettings();
            int portalId = portalSettings.PortalId;
            string defaultPortalAlias = portalSettings.DefaultPortalAlias;
            return defaultPortalAlias;
        }
        catch
        {
            return null;
        }
    }

//Get current tab name by tab id
public string GetCurrentTabName(int tabId)
    {
        DotNetNuke.Entities.Tabs.TabController tabController = new DotNetNuke.Entities.Tabs.TabController();
        DotNetNuke.Entities.Tabs.TabInfo tabInfo = tabController.GetTab(tabId);
        string tabName = tabInfo.TabName;
        return tabName;
    }

//Get current tab id by tabname
    public int GetCurrentTabId(string tabName)
    {
        int PageTabId = 0;
        DotNetNuke.Entities.Tabs.TabInfo objTab = default(DotNetNuke.Entities.Tabs.TabInfo);
        DotNetNuke.Entities.Tabs.TabController objTabs = default(DotNetNuke.Entities.Tabs.TabController);
        objTab = objTabs.GetTabByName(tabName, GetDefaultPortalId());
        PageTabId = objTab.TabID;
        return PageTabId;
    }

 

Best Regards,

Dung Tri

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...How to get individual user box from member directory module.How to get individual user box from member directory module.


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