This code is working, which prevent being deleted by specific title:

add_action( 'delete_attachment', 'check_relations' ); 

    function check_relations( $post_id ){

     if(get_the_title( $post_id )=='ver'){
     wp_die("Sorry, you can't delete this.");

    } }

But I want to prevent an attachment being deleted when the user upload it from a specific url (verification page) example: https://www.example.com/dashboard/settings/verification/

Does anyone know? Thanks.

Also pretty good if can prevent attachment being deleted when submit. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.