How to save Clicks of a downlaod link button while it dosent matter if we refresh the page or again login/logout

Question

I am working on a wordpress site and i am little stuck into one situation , what i want is that:_
(1) I have one resume page, which shows resume posts from wp_postmeta table and each post have a downlaod link button so that users can download that specific post in form of pdf (2) Now the tricky part:- each user can downlaod each post only for 5 times that means one post can be downloaded only 5 times, after 5 times click on downlaod button, the download button disappers(everything working fine till now )(3) what i want now is that saving the clicks of download button; for example:- i have 5 clicks of a downlaod link button of a specific resume post, i used 2 clicks now when i refresh the page i want the remaining 3 clicks not all 5 clicks, on page reload or login/logout of a specific user.
Here below is the screenshot of my resume page

View Image

here below is the js i am using for hiding the buttons after 5 clicks.

<script>
                 $(document).ready(function(){
                     $(".gotocls").click(function() {
                         count= $(this).attr("data-click");
                         count ++;
                             if(count==5){
                                 $(this).hide();
                                         }
                   else{
                        $(this).attr('data-click', count);
                        }
                         });
                     });
            </script>
            
            <a data-click="0" class="dkpdf-button gotocls" href="www.downloadlin.com">Downlaod Resume</a>
0
, , , , Almight Hacker 2 years 2020-09-03T01:10:24-05:00 0 Answers 63 views 0

Leave an answer

Browse
Browse