Only VIP members can download the attachment on the article page. This method can help the website to be converted into members, which is also a great help for website operators, the following uses the official 2.7.2 default template as the basis to describe "how to restrict only VIP members to download relevant attachments on the document details page ".
Assume that the VIP membership level ID is 2.
Modify system files
Open/article. php and add the following function at the end of the file.
The code is as follows: |
Copy code |
Function insert_article_download ($ arr) { Global $ _ LANG; If ($ _ SESSION ['User _ rank '] = 2) { $ Str = '<a href = "'. $ arr ['File _ url']. '"target =" _ blank "> '. $ _ LANG ['relative _ file']. '</a> '; } Else { $ Str = 'only VIP members can download the file. <a href = "user. php"> Log on </a> first! '; } Return $ str; } |
Modify Template File
Next, open the article template page/themes/default/article. dwt and run the following code:
The code is as follows: |
Copy code |
<A href = "{$ article. file_url}" target = "_ blank" >{$ lang. relative_file} </a> Change {Insert name = 'article _ download' file_url = $ article. file_url} |
After the modification, only VIP members can download the attachment. Similarly, you can set it to be downloaded only by "agent members.