Js api set metadata on user?


(Tim Trodd) #1

Hi all,

 

I have created a js api to set the metadata of fields using a form that uses keywords from other bits of content nested in.

 

All working fine if i want to update the metadata of a standard page etc.

 

However what I want to do this time is set the metadata field of the current logged in user, so I am using %globals_user_assetid% to get the current id of the user asset then using it in the below:

 

<a href="#" type="button" class="field" data-asset="%globals_user_assetid%" data-metadata_field="131985" data-metadata_value="example">Complete</a>

 

Then using the below to get them from above to use in the setmetadata api.
        var assetId = $(this).attr('data-asset');
        var fieldId = $(this).attr('data-metadata_field');

 

However it simply won't post to a user account. I have tried posting it using the above but also by manually imputting the user ID in rather than using %globals_user_assetid% but still no luck.

 

I have also tried doing this on different account types sys admin, simple edit etc. and the API has permissions set to ignore and I have even given myself admin permissions for the particular user accounts im trying to update but nothing will work.

 

Any ideas? Like I said works fine when updating a standard page metadata fields just not a "user" asset. Also works fine by updating the metadata in the normal metadata screen of the user asset.

 

 


(Peter McLeod) #2

Hi

Are your user assets linked somewhere under the root node that the JS API is applied to?

I've had this problem before where I've tidied the structure up and moved things out of the root node that the API is applied to.

Thanks

Peter


(Tim Trodd) #3

Hi

Are your user assets linked somewhere under the root node that the JS API is applied to?

I've had this problem before where I've tidied the structure up and moved things out of the root node that the API is applied to.

Thanks

Peter

Hi Peter,

 

Thanks for this! Completely forgot that our users folder is outside of the main site root node which the api was selected too.

 

All working now!

 

Cheers again,

 

Tim