Adding a filter hook for restricting attachments

Implementing attachment restrictions requires us to conditionally check the user permissions and hide the attachment for unauthorized users. So, we need a filter that can modify the output of attachments in list. Let's add a filter to the file list code inside wpqpa_file_attachment_list. We need to replace the following code:

$display .= '      <div class="wpqpa-file-item" id="PF'.$file_row->id.'"  data-file-id="'.$file_row->id.'" >        <div class="wpqpa-file-item-row"    >            <div class="wpqpa-file-item-name wpqpa-files-list-name" >'.$file_row->file_name.'</div>            <div class="wpqpa-file-item-download" ><a href="'.$url.'" >'.__("Download","wpqpa").'</a></div>            <div class="wpqpa-clear"></div>        </div> <div class="wpqpa-clear"></div> ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.