In my application user can publish a custom post from front end . And later admin or capable user can update or delete the post . What I want to do , is to determine if that post is seen by admin or capable user from a dashboard . A post meta "is_seen" is attached to my post , by default it is false . I want to make it true if admin or capable user open the post in edit mode . In short I want to do something when "Edit" link is clicked.

2 Answers 2


You can hook into the loading of any admin screen with

add_action( 'load-post.php', 'tbdn_post_screen' );

function tbdn_post_screen() {
    // Check here whether you're adding a post or
    // editing a post by seeing if $_GET['action']
    // equals 'edit' then add your meta for post with
    // ID $_GET['post']

Details of all of the admin screen load- hook values are at https://codex.wordpress.org/Plugin_API/Admin_Screen_Reference


I have found a solution . If someone click a on "Edit" link or change anything of the post . A new meta field which meta key is "_edit_lock" is added . Thus we can do something when "Edit" link is clicked by

add_action( 'added_post_meta', 'add_custom_field_automatically', 10, 4 );
add_action( 'updated_post_meta', 'add_custom_field_automatically', 10, 4 );
function add_custom_field_automatically( $meta_id, $post_id, $meta_key, $meta_value )
    if ( '_edit_lock' == $meta_key ) {
       //do something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.