Hi there,
I´m having trouble trying to change the metadata of an object. I´m using the same code to create and edit the metadata. The metadata info comes from a form. And the first time the code adds the metadata correctly but next time I try to edit it doesn´t do anything. It keeps the original values. This is the code:
// get the form input
$certificate_spec = get_entity($certificate_guid);
$ind ++;
$certificate_spec->ref1 = $_POST['learning_need'.$ind];
$certificate_spec->ref2 = $_POST['objective'.$ind];
$certificate_spec->ref3 = $_POST['outcome'.$ind];
$certificate_spec->imp1 = $_POST['before_course'.$ind];
$certificate_spec->imp2 = $_POST['after_course'.$ind];
$certificate_spec->imp3 = $_POST['changes'.$ind];
I´ll appreciate any help.
thanks
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
DhrupDeScoop, well done for holding up the Elgg flag. If I knew about the inner workings of Elgg, then I'd be helping out too. Metadata is something I've not got to. I knew more than I did, but not enough to be comfortable advising on this kind of thing.
here are the two lines for updating:
remove_metadata($certificate_guid, 'ref1');
create_metadata($certificate_guid, 'ref1', $val1, 'text', $_SESSION['user']->guid, ACCESS_PUBLIC);
note: I tried the differents type of access...
try :-
remove_metadata($certificate_guid, 'ref1');
create_metadata($certificate_guid, 'ref1', $val1, 'text', $certificate_guid, ACCESS_PUBLIC);
no luck. As soon as I remove the admin privileges from the user, it doesn´t edit. :(
thanks anyway and enjoy the rest of your weekend.
Depending on who is executing the code, and who has write access to the metadata, it may be that you need to use the permissions plugin hook to grant permission.
Try this:
in start.php
And where you are editing your metadata prepend and append the following:
- Previous
- 1
- 2
- Next
You must log in to post replies.