• Resolved Jaso

    (@subwebsites)


    1. How can Users after selecting a plan, be able to delete a listing? There is no option to DELETE

    2. Also, are the attached images also removed from the Media Library ?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, @subwebsites,

    1. You need to disable the Restriction from Directory Listings > Settings > Extensions > Pricing Plans: https://imgbox.com/LcqOg7YN
    2. Currently they do not get removed. If you want them to be removed, you can use this piece of code, just copy-paste this on your functions.php:

    add_action( 'directorist_listing_deleted', 'delete_all_attached_media' );
    function delete_all_attached_media( $listing_id ) {
    
        if( ! $listing_id || ( get_post_type($listing_id) !== "at_biz_dir" )  ) return;
    
        $gallery_images = get_post_meta($listing_id, '_listing_img', false);
    
        $preview_image = get_post_meta($listing_id, '_listing_prv_img', false);
        
        if(!empty($gallery_images) ) {
    
            if( is_array($gallery_images) && $preview_image ){
    
                array_push($gallery_images, $preview_image);
            }
    
            foreach ($gallery_images as $gallery_image) {
    
                wp_delete_attachment( $gallery_image, 'true' );
    
            }
        }
        if( empty($gallery_image) && !empty($preview_image) ) {
            wp_delete_attachment( $preview_image, 'true' );
         }
      
      }

    Kindly use this with caution as it’ll delete all the attachments of a deleted listing, whether those attachments are used with any other listings or not.

    Regards,
    Mahdi.

    • This reply was modified 4 years, 2 months ago by Mahdee.
    • This reply was modified 4 years, 2 months ago by Mahdee.
    • This reply was modified 4 years, 2 months ago by Mahdee.
    • This reply was modified 4 years, 2 months ago by Mahdee.
    Thread Starter Jaso

    (@subwebsites)

    Thanks, I’ll give it a try

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Allow Users to Delete Listings’ is closed to new replies.