WordPress.org

Ready to get started?Download WordPress

Forums

How do I delete element from a serialized array upon deletion of a post? (4 posts)

  1. Waqas
    Member
    Posted 7 months ago #

    I want to delete an element (post id) from a serialized array associated with a specific meta_key. The following screenshot tells the whole story.

    http://i.imgur.com/IMU2mFI.png

    What you're seeing are, post ids saved in a serialized array. Upon deletion of any post the id of the post should be removed from meta_value where meta_key is "whatever". I want to wrap unset for elements (both key and value) inside a function as shown below. Sounds complex to me.

    add_action('before_delete_post', 'upon_deleting_post');
    function upon_deleting_post($post_id){
    ....
    };

    or something like:

    add_action('before_delete_post', 'upon_deleting_post');
    function upon_deleting_post($post_id) {
    delete_metadata (....);
    };
  2. Pioneer Valley Web Design
    Member
    Posted 7 months ago #

  3. Waqas
    Member
    Posted 7 months ago #

    Thats me there.

  4. Pioneer Valley Web Design
    Member
    Posted 7 months ago #

    I know...now use that forum for same.. :-/

Reply

You must log in to post.

About this Topic