Developer forum

Forum » CMS - Standard features » Accessing all user data when sending user details

Accessing all user data when sending user details

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

When I use the "Send user details" option in the backend on a user, I have access to a limited set of fields only:

DWUsers:User:Department
DWUsers:User:Email
DWUsers:User:Name
DWUsers:User:Password
DWUsers:User:Type
DWUsers:User:Username
DWUsers:User:ValidFrom
DWUsers:User:ValidTo
Template:BaseUrl


Is there a way to get access to other user data? Or would I have to use an extender (if so, which one?) or customizations in Razor to get the user based on its user name?

Thanks,

Imar


Replies

 
Alexander Gubenko
Reply
This post has been marked as an answer

Hi Imar,

I think customizations in Razor is good looking way for you. Create razor view using next aprouch:

@{ 
    var userName = GetString("DWUsers:User:Username");
    var usr = Dynamicweb.Modules.UserManagement.User.GetUserByUserName(userName);
}

@helper PrintPublicProperties(Dynamicweb.Modules.UserManagement.User user)
{
    var properties = user.GetType().GetProperties();
    <table>
    @foreach (var p in properties)
    {
        try
        {
            if (!p.CanRead)
            {
                continue;
            }
        <tr>
            <td>@p.Name</td>
            <td>@p.GetValue(user, null)</td>
        </tr>
        }
        catch
        { }
    }
    </table>
}

<strong>email</strong>: @usr.Email
<br />
<strong>Address</strong>: @usr.Address
<br />

<h2>All user properties</h2>
@PrintPublicProperties(usr)

BR, Alexander

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Got it, that makes sense. Thanks!

 

You must be logged in to post in the forum