Using $core_v2_user to Update users profile

Using $core_v2_user to Update users profile

This question is answered

Hi guys,

Trying to update a users profile within a widget, I call '$core_v2_user.Create' which creates the user, how do I then Update the created user's profile fields? Not sure if Im using the $core_v2_widget syntax properly:

               ##set($userResponse = $core_v2_user.Update(options)) - Not updating

               #set($userResponse = $userResponse.Update(options)) - Not updating

How do I tell the 'Update' method which user to update?

Cheers

           ## Call Create User

           #set($userResponse = $core_v2_user.Create($username, $password, $email))

               ##set($userResonse.EnableCommentNotifications = false)

               ##set($userResponse = $core_v2_user.Update(options))

               #set($userResponse = $userResponse.Update(options))

               ##$core_v2_widget.ExecuteFile('UserSaved.vm')

Verified Answer
  • Thanks Alex. 

    Sent from my iPhone

    On 28/09/2012, at 6:45 PM, "Alex Crome" <bounce-afscrome@communities.telligent.com> wrote:

    So the problem here is that the objects you get back from nvelocity are immutable.  To update a property of an object, you need to pass the properties into a separate update method e.g.

    $core_v2_users.Update("%{Id=2100,property=value,property=value,...}")

    The Velocity APIs do not expose EnableCommentNotifications property, so you'll need to set this via the REST endpoint.

All Replies
  • $core_v2_user.Update() should do it. Take a look at the documentation here:

    telligent.com/.../21998.core-v2-user-widget-extension.aspx

    There is also a note about how to update profile fields.

  • I am using the following code to create the user, however when I go into the users Settings>Email the options to turn off "Enable Status Message & Comment Email Notifications" is still on. Is this the right field to update (bolded below) to turn these off?

    #set($userResponse = $core_v2_user.Create($username, $password, $email, $options))
    
    #set($userResonse.EnableCommentNotifications = false)
    
    #set($userResponse = $core_v2_user.Update())
  • Hi Gerard,

    I would like to suggest taking a look at the "Edit User" widget in Widget Studio. To get the results you are looking for you may need to use the REST endpoint "api.ashx/v2/users/{UserId}.json".

    In the "Edit User" widget select the ui.js tab and look at line 171: var data = { ... } down to line 229: $.telligent.evolution.put({ ... }); you'll notice that the EnableCommentNotifications is updated in this call.

    Thanks,

    Rudy Sandoval

  • So are you saying rather than have the Velocity script handle the "create/save" new user, I should use the REST API to send a POST to the User endpoint to handle the create user process?

    Click to show quoted text
  • So the problem here is that the objects you get back from nvelocity are immutable.  To update a property of an object, you need to pass the properties into a separate update method e.g.

    $core_v2_users.Update("%{Id=2100,property=value,property=value,...}")

    The Velocity APIs do not expose EnableCommentNotifications property, so you'll need to set this via the REST endpoint.

  • Thanks Alex. 

    Sent from my iPhone

    On 28/09/2012, at 6:45 PM, "Alex Crome" <bounce-afscrome@communities.telligent.com> wrote:

    So the problem here is that the objects you get back from nvelocity are immutable.  To update a property of an object, you need to pass the properties into a separate update method e.g.

    $core_v2_users.Update("%{Id=2100,property=value,property=value,...}")

    The Velocity APIs do not expose EnableCommentNotifications property, so you'll need to set this via the REST endpoint.