[FAQ]Getting & Displaying Custom Registration Field Data

APGvNext Sam
vNext Dev
  • Total Posts : 13225
  • Joined: 2001/05/23 00:00:00
  • Status: offline
2013/04/02 10:44:31 (permalink) Customization

Getting & Displaying Custom Registration Field Data

Our software has the ability to collect custom data from users on the registration form / profile page. You can define the custom fields in the Custom Registration Fields page in the AdminCP.
This article shows you how to display the data collected on the post page as well as how to get the data in general in case you want to modify the header / footer (or any template files) to include custom data to give your forum a more personalized feel.
  1. Display Custom Registration Field data on the post 
  2. Retrieve Custom Registration Field data anywhere else

Display Custom Registration Field data on the post

In order to display custom reg data on the actual post page, do the following:

1. Enable data retrieval for the field

You can do so by checking the following box in the AdminCP:

2. Customize the post template to show the field data

The template file for posts is ~/App_Templates/BaseTemplate (or your template name)/UC/MessageDisplay/ItemTemplate.ascx
The vb (code) file is ~/App_Code/CommonMessageDisplayClass.vb
The custom reg data are exposed through the property CustomRegFields for the protected variable MDto on the template files:
  • MDto: type ForumMessageDisplayDto
  • MDto.CustomRegFields: type Dictionary(Of String, CustomRegDto)
Since CustomRegFields is a dictionary, you need to access the data via a key. The key for each field is the db column name as shown below:

So for our example, to get the "Gender" data for the author of a post, use
Dim genderData = MDto.CustomRegFields("fld_1").value

Since it is possible to hide the field (user selectable), you can respect the decision by checking
if not MDto.CustomRegFields("fld_1").hidden then ' display only if not hidden

Retrieve Custom Registration Field data anywhere else

On every page and user control, you have access to the current user's basic info through this protected variable MemberInfo (type CurrentUser).
To get the Custom Registration field data for the current logged on user (as opposed to the data for a post), use this method GetCustomRegDataDictionary (returns Dictionary(Of String, CustomRegDto)):
Dim customFields = MemberInfo.GetCustomRegDataDictionary()

You will be able to get data from the dictionary using the same method described above.

Attached Image(s)


1 Reply Related Threads

    New Member
    • Total Posts : 11
    • Joined: 2011/06/17 08:37:04
    • Status: offline
    Re: Getting & Displaying Custom Registration Field Data 2016/12/22 09:43:33 (permalink)
    Recently we moved to a new server with IIS 8.5. We've been getting many more exceptions than we used to. For example, if you go into user settings and click the save button twice, we get a PageRequestManagerServerError Exception. We're running v3.9. Is this something that would be fixed by upgrading to the latest version?
    Jump to:
    © 2019 APG vNext Commercial Version 5.5