this is what im doing... In BuddyPress, before delete user account, if a user has attachments previously uploaded, he or she will be redirected to their own attachments list:
function custom_get_count_before_delete() {
global $bp, $wpdb;
$user_id = $bp->loggedin_user->id;
return $wpdb->get_var( $wpdb->prepare( "
SELECT COUNT(DISTINCT p.ID)
FROM $wpdb->posts p
WHERE p.post_author = %d
AND p.post_status = 'inherit'
AND p.post_type = 'attachment'", $user_id
) );
}
function custom_check_delete_account () {
global $bp;
if ( $bp->current_component == 'settings' && $bp->current_action == 'delete-account' ) {
if ( $count = custom_get_count_before_delete() ) {
wp_redirect('http://www.mysite.lh/wp-admin/upload.php', 301 ); exit;
}
}
}
add_action('init', 'custom_check_delete_account', 11);
My question is: How do I set or inject a message or warning message before to redirect and print it after redirect on the "/wp-admin/upload.php" list of attachments?
Thanks in advance.