• Resolved Alex

    (@alexblack369)


    Hi, I’m interested in your plugin (pro version), but I have a question first: can user somehow delete created custom post? I mean, can I put a button at the end of a custom post which can be used for post deletion from the front-end?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author philkurth

    (@philkurth)

    Hi @alexblack369,

    The plugin only offers the ability to create and edit posts. To delete them, I suggest using WordPress’ get_delete_post_link() function wherever you need it to create delete post links/buttons.

    Cheers,
    Phil

    Thread Starter Alex

    (@alexblack369)

    Hi @philkurth, thank you for the quick answer.

    I’m not proficient in the back end development, so can you help me with some code example which will work with your plugin? Maybe some advice where to put that code?

    I’m sure that your answer will help the others like me who wants to use Advanced Forms for ACF, but also need an credible advice on how to delete a post from the front end.

    Plugin Author philkurth

    (@philkurth)

    Hi @alexblack369,

    So sorry for the slow reply – I actually miss the response notification to this one. You’ve probably work this out by now but here is an example snippet of how you might use the function to offer delete post links in a WordPress loop. Note that this snippet checks whether or not the current user has permission to delete the post:

    <?php
        if ( have_posts() ) {
            while ( have_posts() ) {
                the_post();
                ?>
                <h2><?php the_title(); ?></h2>
                <div><?php the_content(); ?></div>
    
                <?php
                // Check if the current user can delete the post
                if (current_user_can('delete_post', get_the_ID())) {
                    $del_link = get_delete_post_link( get_the_ID() );
                    echo '<a href="' . $del_link . '">Delete Post</a>';
                }
                ?>
                <hr>
                <?php
            }
        }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Delete custom post’ is closed to new replies.