Skip to:

Re: Delete Post by It’s Owner



Here try this – completely untested – let me know!

update: forget this one, use the 2nd one below it

function delete_own_post($retvalue, $capability, $args) {
global $bb_current_user, $bb_post;
if ($capability=="delete_post" && $bb_current_user->ID && $bb_post && $bb_post->post_id && $bb_post->post_id ==intval($args[1]) && $bb_post->poster_id && $bb_post->poster_id==$bb_current_user->ID && bb_current_user_can( 'edit_post', $bb_post->post_id) {return true;} // lots and lots of double checks
return $retvalue;
add_filter('bb_current_user_can', 'delete_own_post',10,3);


This checks if the user can still edit the post, and if so, allows them to delete their own post too.

This plugin could be enhanced by checking if the user has been marked as blocked or inactive and prevent them from deleting it at all.

Update: I may have “over engineered the above function, this may be a much more simplified approach:

function delete_own_post($retvalue, $capability, $args) {
if ($capability=="delete_post") {return bb_current_user_can( 'edit_post', $args[1]);}
return $retvalue;
add_filter('bb_current_user_can', 'delete_own_post',10,3);

This second method simply allows delete if the user can still edit a post. Once the edit times out, so does the delete.

Skip to toolbar