Hi,
I have made a page where the users can see their pictures and can delete them too. This is how I did it:
In bwbps-layout.php I created a custom shortcode called [allow_delete_images]:
case '[allow_delete_images]':
$nonce = wp_create_nonce('bwb_upload_photos');
global $current_user;
get_currentuserinfo();
if ((int)$image['user_id'] == $current_user->ID)
$ret = "<input type='button' value='Eliminar' onclick='bwbpsModerateImageLaVoz(\"burybyuser\",(".$image['psimageID']."),\"\",\"".$nonce."\")'>";
else
$ret = "";
break;
This code call a Javascript function that I have added to bwbps.js. This function is like bwbpsModerateImage function but it receives the nonce param that will be used in the ajax call. This is the code of bwbpsModerateImageLaVoz function:
function bwbpsModerateImageLaVoz(action, image_id, post_id, nonce)
{
var imgid = parseInt('' + image_id);
var myaction = false;
var actiontext = "";
var postid = parseInt('' + post_id);
var img_id_text = " (image id: " + imgid + ")";
var sendMsg = jQuery("#ps_mod_send_msg").attr('checked') ? 1 : 0;
var modMsg = '';
var confirmOn = true;
switch (action) {
case 'burybyuser' :
myaction = 'userdeletewithpost';
actiontext = "eliminar esta fotografía (Nota: al eliminar esta fotografía la eliminará también de la galería a la que pertenezca.) ";
if( sendMsg && !confirm('Is Rejection Moderation Message correct?\n\n ' + jQuery("#").val() )){
return;
} else {
if( sendMsg ){
modMsg = jQuery("#ps_mod_reject_msg").val();
}
}
break;
}
if(!myaction){ alert('Invalid action.'); return false;}
if(confirmOn){
if(!confirm('¿Desea ' + actiontext + '?')){ return false;}
}
var _moderate_nonce = nonce;
var image_caption = '';
var image_url = "";
var image_tags = "";
var meta_data = "";
var file_url = "";
var image_seq = "";
var image_post_id = 0;
try{
$j('#ps_savemsg').show();
}catch(err){}
$j.ajax({
type: 'POST',
url: bwbpsAjaxUserURL,
data: { 'action': myaction,
'image_id': imgid,
'_ajax_nonce' : _moderate_nonce,
'image_caption' : image_caption,
'image_url' : image_url,
'image_tags' : image_tags,
'meta_data' : meta_data,
'file_url' : file_url,
'seq' : image_seq,
'post_id' : postid,
'image_post_id' : image_post_id,
'mod_msg' : modMsg,
'send_msg' : sendMsg
},
dataType: 'json',
success: function(data) {
bwbpsModerateSuccess(data, imgid);
}
});
Sorry for my bad english :S
Hope it helps!