not able to edit metadata

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

  • sorry my ignorance, but how do I get metadata id?

  • read thru
    Elgg1710/mod/profile/actions/edit.php
    for examples of code to handle metadata
    -- there it does 
    remove
    then create
    which == "update"

  • First of all, thanks for your quick answers.

    So I tried this first:

    remove_metadata($certificate_guid,'ref1',$certificate_spec->ref1);

    but is not deleting the data.

  • remove_metadata($guid,$metaname);

    ?

    create_metadata($guid,$metaname,$metavalue,'...',$guid,$access);

    ?

    *read exampe code && *think..

  • I have tried that too. I did read the documentation, I did read the Elgg1710/mod/profile/actions/edit.php you mentioned. And I even thought! And guess what? it didn´t work.

    I know I´m doing something wrong but your method to help people is not working either. thanks for your time though!!!!

  • ;-) Let me check some working code here and post...

  • remove_metadata($user->guid, $v);
    create_metadata(  $user->guid,   $k,    ${$k},   'text',   $user->guid,   $XSL);

    This code is from Live Production Site

     

    Your comment "..method to help people is not working either..: was unkind -- since there's no one else here who has given any time in the past few hours (be thankful) - to try to help you out..  There's not really that much to handling metadata.. My method to help people - for the past 35 years - has been to make them think for themselves, find their own solutions and to never rely on spoon-feeding from others ? Has worked so far... ;-)

  • Like I said before, thanks for your help and I apologize if my words did hurt your feelings. It wasn´t my intention.

    I found the problem after hours of testing and commenting the create_metadata function. It ended up being a access_id issue. I solved it momentarily setting as admin the testing user, but I need to find out why the normal testing user could create the metadata the first time and didn´t have permission to update.

  • post yr code here for remove & create metadata.

    my feelings not hurt ;) but while no one else is helping...

    know who yr code 'friends' are ;-o