This function allows you to get DNN profile properties from the system.
You can even ask for custom properties you added yourself.
CREATE FUNCTION [dbo].[BIT_GetPropertyValue]
(
@PortalID int, -- portalid
@UserID int, -- UserID
@Property nvarchar(100) -- name of the property to read
)
RETURNS nVarChar(4000) -- the value of the property for the user
AS
BEGIN
DECLARE @RetVal AS nVarChar(4000) = ''
select @RetVal = PropertyValue
from UserProfile
where UserID = @UserID
and PropertyDefinitionID = dbo.GetProfilePropertyDefinitionID (@PortalID,@Property)
RETURN @RetVal
END