Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Delete a post
- *
- * Only post author and editors has the capability to delete a post
- */
- function delete_post() {
- global $userdata;
- $nonce = $_REQUEST['_wpnonce'];
- if ( !wp_verify_nonce( $nonce, 'wpuf_del' ) ) {
- die( "Security check" );
- }
- //check, if the requested user is the post author
- $maybe_delete = get_post( $_REQUEST['pid'] );
- if ( ($maybe_delete->post_author == $userdata->ID) || current_user_can( 'delete_others_pages' ) ) {
- wp_delete_post( $_REQUEST['pid'] );
- //redirect
- $redirect = add_query_arg( array('msg' => 'deleted'), get_permalink() );
- wp_redirect( $redirect );
- } else {
- echo '<div class="error">' . __( 'You are not the post author. Cheeting huh!', 'wpuf' ) . '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement