Title: insert PHP code in the right way
Last modified: September 24, 2019

---

# insert PHP code in the right way

 *  Resolved [ariebl](https://wordpress.org/support/users/ariebl/)
 * (@ariebl)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/inswert-php-code/)
 * Hello
    The following PHP code let alloy the user to delete a post But I have 
   difficulties insert it to “Woody AD SNIPPETS” plugin according the php code inside
   it I am not expert in PHP I founded this code in clicknathan website and it is
   working in another plugin, but I want it works in “Woody AD SNIPPETS” plugin 
   since I want it to be add automatically to any post Can you help me please?
 *     ```
       <?php if ($post->post_author == $current_user->ID) { ?>
          <p><a onclick="return confirm('Are you SURE you want to delete this post?')" href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p>
       <?php } ?>
       ```
   
    -  This topic was modified 6 years, 8 months ago by [ariebl](https://wordpress.org/support/users/ariebl/).
    -  This topic was modified 6 years, 8 months ago by [ariebl](https://wordpress.org/support/users/ariebl/).
    -  This topic was modified 6 years, 8 months ago by [ariebl](https://wordpress.org/support/users/ariebl/).
    -  This topic was modified 6 years, 8 months ago by [ariebl](https://wordpress.org/support/users/ariebl/).

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

 *  [Temyk](https://wordpress.org/support/users/webtemyk/)
 * (@webtemyk)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/inswert-php-code/#post-11966101)
 * Hello.
 * Of course, nothing complicated. You need to create a Universal snippet with this
   code
 *     ```
       <?php
       global $post;
       $current_user = wp_get_current_user();
       if ($current_user && $post->post_author == $current_user->ID)
       {
       ?>
          <p>
       	   <a onclick="return confirm('Are you SURE you want to delete this post?')" href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p>
       <?php 
       }
       ?>
       ```
   
 * and such settings
    [https://imgur.com/rngTBmR](https://imgur.com/rngTBmR) (screenshot)
   You can change the insertion location
    -  This reply was modified 6 years, 8 months ago by [Temyk](https://wordpress.org/support/users/webtemyk/).
    -  This reply was modified 6 years, 8 months ago by [Temyk](https://wordpress.org/support/users/webtemyk/).
 *  Thread Starter [ariebl](https://wordpress.org/support/users/ariebl/)
 * (@ariebl)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/inswert-php-code/#post-11966287)
 * It is working!!! Thank you very much Temyk!!!

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

The topic ‘insert PHP code in the right way’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 2 participants
 * Last reply from: [ariebl](https://wordpress.org/support/users/ariebl/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/inswert-php-code/#post-11966287)
 * Status: resolved