Delete value by key in user meta array in WordPress












2















I've this array set to a WordPress user on my WordPress page:



Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)

)


To receive this array I'm doing this:



$get_ids = get_user_meta( 3, 'additional_ids', false );




So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta. So I thirst tried to find out the key by the value which works good for the moment:



$key = array_search( (int) $value, $get_ids[0], true );


So I've found out now that the key is [0]. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:



Array
(
[0] => Array
(
[0] => 1597
)

)


This is what I've tried:



//Unset element to delete from the array
unset( $get_ids[0][ $key ] );


//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );


But when I do this the array is totally messed up and not longer readable.










share|improve this question

























  • Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

    – Shashidhara
    Nov 26 '18 at 6:49













  • There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

    – Mr. Jo
    Nov 26 '18 at 6:53













  • Use array_pop($get_ids[0]);. Note: it always removes first element.

    – Shashidhara
    Nov 26 '18 at 6:58
















2















I've this array set to a WordPress user on my WordPress page:



Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)

)


To receive this array I'm doing this:



$get_ids = get_user_meta( 3, 'additional_ids', false );




So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta. So I thirst tried to find out the key by the value which works good for the moment:



$key = array_search( (int) $value, $get_ids[0], true );


So I've found out now that the key is [0]. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:



Array
(
[0] => Array
(
[0] => 1597
)

)


This is what I've tried:



//Unset element to delete from the array
unset( $get_ids[0][ $key ] );


//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );


But when I do this the array is totally messed up and not longer readable.










share|improve this question

























  • Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

    – Shashidhara
    Nov 26 '18 at 6:49













  • There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

    – Mr. Jo
    Nov 26 '18 at 6:53













  • Use array_pop($get_ids[0]);. Note: it always removes first element.

    – Shashidhara
    Nov 26 '18 at 6:58














2












2








2








I've this array set to a WordPress user on my WordPress page:



Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)

)


To receive this array I'm doing this:



$get_ids = get_user_meta( 3, 'additional_ids', false );




So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta. So I thirst tried to find out the key by the value which works good for the moment:



$key = array_search( (int) $value, $get_ids[0], true );


So I've found out now that the key is [0]. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:



Array
(
[0] => Array
(
[0] => 1597
)

)


This is what I've tried:



//Unset element to delete from the array
unset( $get_ids[0][ $key ] );


//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );


But when I do this the array is totally messed up and not longer readable.










share|improve this question
















I've this array set to a WordPress user on my WordPress page:



Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)

)


To receive this array I'm doing this:



$get_ids = get_user_meta( 3, 'additional_ids', false );




So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta. So I thirst tried to find out the key by the value which works good for the moment:



$key = array_search( (int) $value, $get_ids[0], true );


So I've found out now that the key is [0]. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:



Array
(
[0] => Array
(
[0] => 1597
)

)


This is what I've tried:



//Unset element to delete from the array
unset( $get_ids[0][ $key ] );


//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );


But when I do this the array is totally messed up and not longer readable.







php arrays wordpress multidimensional-array






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 6:51







Mr. Jo

















asked Nov 26 '18 at 6:40









Mr. JoMr. Jo

675115




675115













  • Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

    – Shashidhara
    Nov 26 '18 at 6:49













  • There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

    – Mr. Jo
    Nov 26 '18 at 6:53













  • Use array_pop($get_ids[0]);. Note: it always removes first element.

    – Shashidhara
    Nov 26 '18 at 6:58



















  • Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

    – Shashidhara
    Nov 26 '18 at 6:49













  • There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

    – Mr. Jo
    Nov 26 '18 at 6:53













  • Use array_pop($get_ids[0]);. Note: it always removes first element.

    – Shashidhara
    Nov 26 '18 at 6:58

















Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

– Shashidhara
Nov 26 '18 at 6:49







Means, there are chances of multiple arrays and you dont want to specify $get_ids[0] right?

– Shashidhara
Nov 26 '18 at 6:49















There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

– Mr. Jo
Nov 26 '18 at 6:53







There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.

– Mr. Jo
Nov 26 '18 at 6:53















Use array_pop($get_ids[0]);. Note: it always removes first element.

– Shashidhara
Nov 26 '18 at 6:58





Use array_pop($get_ids[0]);. Note: it always removes first element.

– Shashidhara
Nov 26 '18 at 6:58












2 Answers
2






active

oldest

votes


















3














The first thing we need to address is how you added the meta to your user. If you use add_user_meta, you can add multiple meta values under the same meta key. Like this:



//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);


Doing this will add both 1509 and 1597 to the user meta additional_ids.



If you've added the meta fields this way, it will allow you to get all values by using get_user_meta like this:



$additional_ids = get_user_meta(3, 'additional_ids', false);


Which will return an array like this:



Array (
[0] => 1597
[1] => 1509
)


You can however delete any value from the array without grabbing the array first by using delete_user_meta(); to remove that specific value.



Like this:



delete_user_meta( 3, 'additional_ids', 1509 );


Which would mean that if you get the additional ids again, it would look like this:



$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)


The third argument inside that function will ensure that only metadata with that specific value will be removed.



Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.






share|improve this answer


























  • Tried exact the same thing but the array is still the same after doing the delete function.

    – Mr. Jo
    Nov 26 '18 at 7:10











  • Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

    – Frits
    Nov 26 '18 at 7:15








  • 1





    @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

    – Frits
    Nov 26 '18 at 12:20








  • 1





    I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

    – Mr. Jo
    Nov 26 '18 at 14:11






  • 1





    @Mr.Jo I’m super happy to have helped :)

    – Frits
    Nov 26 '18 at 18:09



















1














after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again



//Unset element to delete from the array
unset( $get_ids[0][ $key ] );

// rebase the array
$get_ids[0] = array_values( $get_ids[0] );

//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475892%2fdelete-value-by-key-in-user-meta-array-in-wordpress%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    The first thing we need to address is how you added the meta to your user. If you use add_user_meta, you can add multiple meta values under the same meta key. Like this:



    //add_user_meta( $user_id, $meta_key, $meta_value, $unique );
    add_user_meta(3, 'additional_ids', 1597, false);
    add_user_meta(3, 'additional_ids', 1509, false);


    Doing this will add both 1509 and 1597 to the user meta additional_ids.



    If you've added the meta fields this way, it will allow you to get all values by using get_user_meta like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);


    Which will return an array like this:



    Array (
    [0] => 1597
    [1] => 1509
    )


    You can however delete any value from the array without grabbing the array first by using delete_user_meta(); to remove that specific value.



    Like this:



    delete_user_meta( 3, 'additional_ids', 1509 );


    Which would mean that if you get the additional ids again, it would look like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);
    print_r($additional_ids);
    //prints out:
    Array (
    [0] => 1597
    )


    The third argument inside that function will ensure that only metadata with that specific value will be removed.



    Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.






    share|improve this answer


























    • Tried exact the same thing but the array is still the same after doing the delete function.

      – Mr. Jo
      Nov 26 '18 at 7:10











    • Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

      – Frits
      Nov 26 '18 at 7:15








    • 1





      @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

      – Frits
      Nov 26 '18 at 12:20








    • 1





      I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

      – Mr. Jo
      Nov 26 '18 at 14:11






    • 1





      @Mr.Jo I’m super happy to have helped :)

      – Frits
      Nov 26 '18 at 18:09
















    3














    The first thing we need to address is how you added the meta to your user. If you use add_user_meta, you can add multiple meta values under the same meta key. Like this:



    //add_user_meta( $user_id, $meta_key, $meta_value, $unique );
    add_user_meta(3, 'additional_ids', 1597, false);
    add_user_meta(3, 'additional_ids', 1509, false);


    Doing this will add both 1509 and 1597 to the user meta additional_ids.



    If you've added the meta fields this way, it will allow you to get all values by using get_user_meta like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);


    Which will return an array like this:



    Array (
    [0] => 1597
    [1] => 1509
    )


    You can however delete any value from the array without grabbing the array first by using delete_user_meta(); to remove that specific value.



    Like this:



    delete_user_meta( 3, 'additional_ids', 1509 );


    Which would mean that if you get the additional ids again, it would look like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);
    print_r($additional_ids);
    //prints out:
    Array (
    [0] => 1597
    )


    The third argument inside that function will ensure that only metadata with that specific value will be removed.



    Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.






    share|improve this answer


























    • Tried exact the same thing but the array is still the same after doing the delete function.

      – Mr. Jo
      Nov 26 '18 at 7:10











    • Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

      – Frits
      Nov 26 '18 at 7:15








    • 1





      @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

      – Frits
      Nov 26 '18 at 12:20








    • 1





      I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

      – Mr. Jo
      Nov 26 '18 at 14:11






    • 1





      @Mr.Jo I’m super happy to have helped :)

      – Frits
      Nov 26 '18 at 18:09














    3












    3








    3







    The first thing we need to address is how you added the meta to your user. If you use add_user_meta, you can add multiple meta values under the same meta key. Like this:



    //add_user_meta( $user_id, $meta_key, $meta_value, $unique );
    add_user_meta(3, 'additional_ids', 1597, false);
    add_user_meta(3, 'additional_ids', 1509, false);


    Doing this will add both 1509 and 1597 to the user meta additional_ids.



    If you've added the meta fields this way, it will allow you to get all values by using get_user_meta like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);


    Which will return an array like this:



    Array (
    [0] => 1597
    [1] => 1509
    )


    You can however delete any value from the array without grabbing the array first by using delete_user_meta(); to remove that specific value.



    Like this:



    delete_user_meta( 3, 'additional_ids', 1509 );


    Which would mean that if you get the additional ids again, it would look like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);
    print_r($additional_ids);
    //prints out:
    Array (
    [0] => 1597
    )


    The third argument inside that function will ensure that only metadata with that specific value will be removed.



    Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.






    share|improve this answer















    The first thing we need to address is how you added the meta to your user. If you use add_user_meta, you can add multiple meta values under the same meta key. Like this:



    //add_user_meta( $user_id, $meta_key, $meta_value, $unique );
    add_user_meta(3, 'additional_ids', 1597, false);
    add_user_meta(3, 'additional_ids', 1509, false);


    Doing this will add both 1509 and 1597 to the user meta additional_ids.



    If you've added the meta fields this way, it will allow you to get all values by using get_user_meta like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);


    Which will return an array like this:



    Array (
    [0] => 1597
    [1] => 1509
    )


    You can however delete any value from the array without grabbing the array first by using delete_user_meta(); to remove that specific value.



    Like this:



    delete_user_meta( 3, 'additional_ids', 1509 );


    Which would mean that if you get the additional ids again, it would look like this:



    $additional_ids = get_user_meta(3, 'additional_ids', false);
    print_r($additional_ids);
    //prints out:
    Array (
    [0] => 1597
    )


    The third argument inside that function will ensure that only metadata with that specific value will be removed.



    Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 26 '18 at 12:18

























    answered Nov 26 '18 at 6:55









    FritsFrits

    4,312102337




    4,312102337













    • Tried exact the same thing but the array is still the same after doing the delete function.

      – Mr. Jo
      Nov 26 '18 at 7:10











    • Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

      – Frits
      Nov 26 '18 at 7:15








    • 1





      @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

      – Frits
      Nov 26 '18 at 12:20








    • 1





      I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

      – Mr. Jo
      Nov 26 '18 at 14:11






    • 1





      @Mr.Jo I’m super happy to have helped :)

      – Frits
      Nov 26 '18 at 18:09



















    • Tried exact the same thing but the array is still the same after doing the delete function.

      – Mr. Jo
      Nov 26 '18 at 7:10











    • Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

      – Frits
      Nov 26 '18 at 7:15








    • 1





      @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

      – Frits
      Nov 26 '18 at 12:20








    • 1





      I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

      – Mr. Jo
      Nov 26 '18 at 14:11






    • 1





      @Mr.Jo I’m super happy to have helped :)

      – Frits
      Nov 26 '18 at 18:09

















    Tried exact the same thing but the array is still the same after doing the delete function.

    – Mr. Jo
    Nov 26 '18 at 7:10





    Tried exact the same thing but the array is still the same after doing the delete function.

    – Mr. Jo
    Nov 26 '18 at 7:10













    Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

    – Frits
    Nov 26 '18 at 7:15







    Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you get_user_meta you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta appropriately. - hope it helps :) @Mr.Jo

    – Frits
    Nov 26 '18 at 7:15






    1




    1





    @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

    – Frits
    Nov 26 '18 at 12:20







    @Mr.Jo - ah, that's because I made a mistake with the add_user_meta() third argument, it should be false, not true. I've edited my answer to show the correct statement :)

    – Frits
    Nov 26 '18 at 12:20






    1




    1





    I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

    – Mr. Jo
    Nov 26 '18 at 14:11





    I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.

    – Mr. Jo
    Nov 26 '18 at 14:11




    1




    1





    @Mr.Jo I’m super happy to have helped :)

    – Frits
    Nov 26 '18 at 18:09





    @Mr.Jo I’m super happy to have helped :)

    – Frits
    Nov 26 '18 at 18:09













    1














    after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again



    //Unset element to delete from the array
    unset( $get_ids[0][ $key ] );

    // rebase the array
    $get_ids[0] = array_values( $get_ids[0] );

    //Save it again in the database
    update_user_meta( 3, 'additional_ids', $get_ids, false );





    share|improve this answer




























      1














      after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again



      //Unset element to delete from the array
      unset( $get_ids[0][ $key ] );

      // rebase the array
      $get_ids[0] = array_values( $get_ids[0] );

      //Save it again in the database
      update_user_meta( 3, 'additional_ids', $get_ids, false );





      share|improve this answer


























        1












        1








        1







        after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again



        //Unset element to delete from the array
        unset( $get_ids[0][ $key ] );

        // rebase the array
        $get_ids[0] = array_values( $get_ids[0] );

        //Save it again in the database
        update_user_meta( 3, 'additional_ids', $get_ids, false );





        share|improve this answer













        after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again



        //Unset element to delete from the array
        unset( $get_ids[0][ $key ] );

        // rebase the array
        $get_ids[0] = array_values( $get_ids[0] );

        //Save it again in the database
        update_user_meta( 3, 'additional_ids', $get_ids, false );






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 8:21









        Ash0urAsh0ur

        569128




        569128






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475892%2fdelete-value-by-key-in-user-meta-array-in-wordpress%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)