88519

How do you properly set a custom profile property in DNN?

I'm trying to save a custom property to an existing user profile in DNN 7, but the profile property is not getting set. I must be understanding something incorrectly.

So, how do you properly set a custom profile property in DNN?

UserInfo.Profile.SetProfileProperty("key","value") // I expect this to return "value", but it's always "" var value = UserInfo.Profile.GetProfileProperty("key"); // Even if I save it... ProfileController.UpdateUserProfile(UserInfo); // It always returns "" var savedValue = UserInfo.Profile.GetProfileProperty("key");

Note: I also tried InitialiseProfile but that didn't change the behavior.

Answer1:

Here is how I am accessing a propertyvalue from a property in a module base class I have for a client.

public string SomeKey { get { var ppd = UserInfo.Profile.GetProperty("SomeKey"); if (ppd.PropertyValue == string.Empty) { var SomeKeyValue = "blah" //update the user's profile property UserInfo.Profile.SetProfileProperty("SomeKey", SomeKeyValue); //save the user DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, UserInfo); //retrieve again return SomeKey; } string returnValue = ppd.PropertyValue ?? (String.IsNullOrEmpty(ppd.DefaultValue) ? String.Empty : ppd.DefaultValue); return returnValue; } }

Recommend

  • Symfony2 - Call to undefined method getDoctrine() when overriding FOSUserBundle's ProfileContro
  • Uncaught exception 'MongoConnectionException'
  • Symfony2 A session had already been started - ignoring session_start()
  • wordpress featured image uploader not working
  • django start celery daemon in production with supervisor
  • Zend Framework: only index view renders 404 error when trying to access other views via /controller/
  • CakePHP 3.0 not running without intl extension
  • how to install mysqli on windows iis server?
  • cakephp emails not working
  • Warning: mail(): Failed to Receive in
  • How to mail a log file to yourself using PHP from a Windows machine ?
  • error: expected unqualified-id before string constant
  • Autoloading classes when not in same directory as zend library
  • Pip behind a proxy with a custom certificate file
  • Increase the limit of file upload size in Heroku while uploading to Dropbox
  • Get highest value from a file using mSL and mIRC
  • Enabling domxml in php
  • Change of MySQL database location not working
  • Changing MySQL charset to UTF8 on linux so it will work with JDBC
  • In-place sed command not working
  • Eloquent paginate function in Slim 3 project using twig
  • Install PHP intl extension on MacOS
  • ilmerge with a PFX file
  • Why value captured by reference in lambda is broken? [duplicate]
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • How to delete a row from a dynamic generate table using jquery?
  • using HTMLImports.whenReady not working in chrome
  • Why joiner is not used after Sequence generator or Update statergy
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Authorize attributes not working in MVC 4
  • Bitwise OR returns boolean when one of operands is nil
  • EntityFramework adding new object to nested object collection
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Recursive/Hierarchical Query Using Postgres
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • How to push additional view controllers onto NavigationController but keep the TabBar?