• Resolved geraldmenzel

    (@geraldmenzel)


    Is it possible to add a ‘Delete Post’ button next to the update button on a post edit page? If so, how? If not, please consider adding this option. It would be tremendously useful to me. Thanks!

    • This topic was modified 5 years, 3 months ago by geraldmenzel.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello @geraldmenzel

    Make sure you have enabled the option to let the user delete their posts. Navigate to wp-admin->User Frontend->Settings->Dashboard->Set ‘yes’ for user can delete their posts. Reference screenshot: https://prnt.sc/ooiten

    I hope this will help ??

    Regards

    Thread Starter geraldmenzel

    (@geraldmenzel)

    Thanks, but this is not what I meant.

    As my site does not make use of WPUF’s dashboard feature, but rather uses custom edit links for user posts (via a custom shortcode), I would like to have the option to include a ‘Delete’ button directly on the edit page for user posts.

    Hello @geraldmenzel

    This brings a delete button on the user dashboard just after the edit button. Reference screenshot: https://prnt.sc/ooj6ll

    I’m not sure what did you mean by custom edit links. But this is the only default way to let the user delete their posts.

    Thanks

    Thread Starter geraldmenzel

    (@geraldmenzel)

    Yes, I’m aware that WPUF’s own dashboard provides a delete button. Unfortunately, my site is a WooCommerce site and therefore already has a user dashboard. Since the two dashboards do not integrate into one, I cannot use WPUF’s dashboard, as this would cause too much confusion.

    Instead I have created a custom shortcode that simply adds a link to WPUF’s post edit page to all user posts.

    function func_wpuf_edit_link($atts) {
    	return wp_nonce_url( '/edit-user-gallery/?pid=' . $atts['post-id'], 'wpuf_edit' );
    }
    add_shortcode( 'wpuf_edit_link', 'func_wpuf_edit_link' );

    This works nicely. What is missing is a way for users to be able to delete their own posts. Hence my request for a delete button directly on the edit page for user posts, i.e. next to the update button. This should be trivial to implement and would be very useful.

    You can try the following example codes:

    <?php
    if ( wpuf_get_option( 'enable_post_del', 'wpuf_dashboard', 'yes' ) == 'yes' ) {
        $del_url = add_query_arg( array('action' => 'del', 'pid' => $post->ID) );
        $message = __( 'Are you sure to delete?', 'wp-user-frontend' );
        
        ?>
        <a href="<?php echo wp_nonce_url( $del_url, 'wpuf_del' ) ?>" onclick="return confirm('<?php echo $message ?>');"><span style="color: red;"><?php _e( 'Delete', 'wp-user-frontend' ); ?></span></a>
    <?php } ?>

    You need to pass your post ID here.

    I hope this will help.

    Regards,

    Thread Starter geraldmenzel

    (@geraldmenzel)

    Thanks, Mehedi!

    The generated link does not actually delete the post, unfortunately. It just returns to the same page with the post still there.

    I had tried something similar already. I figured that the action would need to be directed at WPUF’s account page to work, in the same way that the edit action needs to call the post edit page.

    Hence my idea to add a delete button to the edit page as a quick and easy to implement solution.

    Thread Starter geraldmenzel

    (@geraldmenzel)

    Are you still there, Mehedi?

    Should your code snipped have worked? Am I doing something wrong?

    Will my suggestion be considered? Please let me know. Thanks.

    Thread Starter geraldmenzel

    (@geraldmenzel)

    Uhm…

    Hello @geraldmenzel

    It’s getting difficult for us to understand what is happening on your site without debugging it. I’d recommend you to contact our support center referring our conversation here.

    We’ll help you out ??

    Thanks

    Hello!
    I have the same problem as “geraldmenzel”.

    Have you found a solution for this?

    Thanks!!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Delete button in post edit form’ is closed to new replies.