Cannot delete posts from frontend.
-
Hello, I have been editing my wpuf files for some time today to make them suit my needs. However, upon testing the functionality of the Dashboard I’ve stumbled upon an error.
While deleting the post it sends the following error message to the page:
You are not the post author. Cheeting huh!
I looked into wpuf-dashboard.php file for the post-deletion code and found this.
/** * Delete a post * * Only post author and editors has the capability to delete a post */ function delete_post() { $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>'; } }
I’m not sure why it is not working, I tried printing the $maybe_delete variable in the browser which gave me another error:
Catchable fatal error: Object of class WP_Post could not be converted to string in /wp-content/plugins/wp-user-frontend/wpuf-dashboard.php on line 212
Is the code broken? Did I break it?
https://www.ads-software.com/extend/plugins/wp-user-frontend/
- The topic ‘Cannot delete posts from frontend.’ is closed to new replies.