• Resolved kevinmrlw

    (@kevinmrlw)


    Hello,

    The newest update from 1.6.0 the add_action( ‘delete_post’,..) action was updated.
    It seems logical/recommended to use a WP way of delete WP post meta, but there is a gotcha..which caused quite a lot of pain…

    The problem in short: when POST revision is deleted, the custom permalink is deleted for a parent an actual post. Because delete_post_meta is used and is even said, that Post provided ID is revision, it takes an ID of a parent and do action – on it, not on revision itself.

    The problem flow:

    1. We have a limitation of keeping top max 10 revisions, in WP config
    define( ‘WP_POST_REVISIONS’, 10 );
    2. Manager entered a post in admin, pressed EDIT
    3. On edit page load (even without save), WP decided to remove POST revision to keep with set amount of revisions
    4. The delete action was inited for a revision
    5. Though as delete_post_meta is used, the WP took current/parent post’s ID and deleted a custom permalink from DB, for an actual post

    6. The post URL changes, even though you might actually didn’t do any changes. Or if you did not noticed that permalink was deleted, you press save and permalink is taken from post title (which can be different to what is wanted)

    A fix:

    change method logic to:

    public function delete_permalink( $post_id )
    {
    delete_metadata( ‘post’, $post_id, ‘custom_permalink’, ” );
    }

    Or leave your previous code logic from 1.5* version 😉 which maybe not ideal, but at least it worked..

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sami Ahmed Siddiqui

    (@sasiddiqui)

    Hi @kevinmrlw

    Thank you for pointing this out. I have fixed this issue and released v1.7.0 with some other updates.

    Please update the plugin and verify this issue so I can mark this thread as resolved.

    Let me know if you have any questions.

    Regards,
    Sami

    Plugin Author Sami Ahmed Siddiqui

    (@sasiddiqui)

    Hi @kevinmrlw

    I am marking this topic as resolved. If the issue still persist for you then please reopen this topic and let me know.

    Regards,
    Sami

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘A problem with wrongly deleted permalinks’ is closed to new replies.