Adding current user’s ID to the end of PDF hyperlinks in post content
Here’s a solution that I came up with that will add the user query argument and the current user’s ID to PDF links, e.g.: http://mysite/wp-content/uploads/2018/12/My_PDF_File.pdf?user=54 This code works by inspecting the post’s content using the the_content filter, then parsing the content using DOMDocument. I’ve run into various gotchas using DOMDocument and much of this code … Read more