TCPDF only exports .pdf when user is administrator

This was due to 2 mistakes in code restricting client access to wp-admin.

  • There was no exception for admin-post.php , so after a request to admin-post the client was redirected back to client area. Hence the ‘reloads’ after clicking the link.
  • After the redirect in the restriction code, there was no die() or exit statement. Therefore the admin-post handler was able to continue running and TCPDF was able to set some HTTP response header info (content type: pdf), but HTTP status 302 was already sent and no file was downloaded. This confused me quite a lot.