Support » Plugins and Hacks » Hacks » Delete post of user with button

  • Resolved zinc1314

    (@zinc1314)


    Hi!

    Someone know how i can show on front of wordpress, a button for delete entries of logged users?

    I have this code, but is only for back (admin)

    <?php
    function mqw_add_admin_bar_trash_menu() {
      global $wp_admin_bar;
      if ( !is_super_admin() || !is_admin_bar_showing() )
          return;
      $current_object = get_queried_object();
      if ( empty($current_object) )
          return;
      if ( !empty( $current_object->post_type ) &&
         ( $post_type_object = get_post_type_object( $current_object->post_type ) ) &&
         current_user_can( $post_type_object->cap->edit_post, $current_object->ID )
      ) {
        $wp_admin_bar->add_menu(
            array( 'id' => 'borrar',
                'title' => __('Borrar post'),
                'href' => get_delete_post_link($current_object->term_id)
            )
        );
      }
    }
    add_action( 'admin_bar_menu', 'mqw_add_admin_bar_trash_menu', 35 );
    ?>

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Add a link to the content.php template, much like the link for ‘Trash’ (or the equivalent for your language) that appears below posts on hover over the posts table. The href is of the form http://example.com/wp-admin/post.php?post=$post_id&action=trash&_wpnonce=$nonce.

    $nonce is generated with wp_create_nonce( 'trash-post_' . $post_id );. The link output code must be conditional on if(current_user_can('delete_posts')).

    sorry, i take other option. thanks anyway!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete post of user with button’ is closed to new replies.