• Resolved ariebl

    (@ariebl)


    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 5 years, 5 months ago by ariebl.
    • This topic was modified 5 years, 5 months ago by ariebl.
    • This topic was modified 5 years, 5 months ago by ariebl.
    • This topic was modified 5 years, 5 months ago by ariebl.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Temyk

    (@webtemyk)

    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 (screenshot)
    You can change the insertion location

    • This reply was modified 5 years, 5 months ago by Temyk.
    • This reply was modified 5 years, 5 months ago by Temyk.
    Thread Starter ariebl

    (@ariebl)

    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.