Modifying user settings and profile fields programmatically

I am writing a web service (Modifying create user web service ) to modify user settings ( name and password) and profile fields ( Interests and Location) . But it is not working as expected. Could somebody please help me?


1)    User settings :-
        $userObj=get_user_by_username(‘myusername’);
                             $ userObj ->name=’Modified Name’;
        $ userObj ->save();
            I printed $ userObj , it has values what I expected from database .   I tried even with entity, but that is also not working. 


2)    Profile Fields
      update_metadata ($userObj->guid, 'Interests', 'Dancing’, '', 0, ACCESS_PUBLIC);

Already ‘Interests‘value is defined .I am just trying to modify it. Even this one not working

Am I missing some basics?

Regards
Kiran

  • Thanks Cash for your immediate response. Could you please refer me anything that (or any code) I can use to "log the user in programmatically to the Elgg site"?
    Regards
    Kiran

     

  • I am trying using register_pam_handler to authenticate but since I am using XML-RPC , I am regsitering two handlers register_xmlrpc_handler and other register_pam_handler . I am getting the data from register_xmlrpc_handler method and manually trying to pass the credentials to register_pam_handlerhandler . But not sure this is the way I have to do and any way not woring :( . Tried from http://docs.elgg.org/wiki/Engine/Authentication

    any ideas on authenticating user using XML-RPC?

    Regards

    Kiran

  • I think too much and that eats my lot of time .

    I made profile settings update working . here is the code I used

    $user_object = authenticate('Myuserid','mypassword');
     $result = login($user_object, true);
    $user_modify=get_loggedin_user();
    $user_modify->name='new name'
    $user_modify->save();

    Never thought so simple :)

    But again for metadata update i got struck

    using update_metadata method to update the metadata but some how still not working .

    I just user this command

     update_metadata ($user_modify->guid, 'Interests', 'Dancing', '', 0, ACCESS_PUBLIC);

    am I doing some thing wrong ?

    Thanks for your help

    Regards

    Kiran

  • Thanks a lot every one for your help . I am able to resolve all my issues .

  • Hi Bujji,

    Can you tell me how you could update the custom fields.

    Can you provide a sample scode snippet please.

    Thanks inadvance,

    Balakrishna.