WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Wordpress to run a membership site, and one of the features is that members can download a badge. However, they are only allowed to download the badge once per year, starting form the date they joined, which I have stored in my database.

They can access the badge from a link on the homepage when they are logged. prior to downloading the badge, they have to fill in some personal details that are then entered onto the badge.

I would to like to do the following:

  1. If the member hasn't downloaded the badge then when they click the link, they are taken to the next page.
  2. If they have downloaded the badge, then they are taken to a different page saying "You have already downloaded this file"

I was thinking that the best way would be to count the number of downloads using a new table in my database and then comopare todays date with their start date. Unfortunately, I'm a bit concerned about adding random tables to the DB

Any pointers would be great. I've looked at some download plugins, but they don't seem to do the job...

Thanks in advance

Edit to add:

I've had a go at building something but nothing seems to be happening so i must be missing something. Code is below:


if (is_user_logged_in()) {

    global $user_ID;
    $paypal_user = get_user_meta($user_ID, 'paypal_user', true);
    $download = get_user_meta($user_ID, 'badge_dl', true);
    $exp_date = $paypal_user->expire_date;
    $currentDate = date('Y-m-d');

    if (($currentDate <= $exp_date) and ($download == 'yes')) { ?>

    <li><a href="downloaded.php">Member Downloads</a></li>

    <?php } 

    else { ?>

    <li><a href="member_badge_lp.php" onClick="<?php update_user_meta($user_ID, 'badge_dl', 'yes'); ?>">Member Downloads</a></li>   

    <?php }


Any ideas why it might not be working?

Thanks again.

share|improve this question

You got the native date( 'Y' ); function that will give you in that case the current year. Combine that with some if/else statement and wp_redirect( $location, $header );and you're almost finished. It's as easy as using user meta data $current_user to check and so on.

Btw: no need to add any extra tables. Just use add_user_meta(), update_user_meta() & get_user_meta() functions.

Update: Try to only use a single meta field per user and store your data in there as an array to avoid polluting the table too much.

share|improve this answer
If there aren't a lot of links I think this is definitely the route to go. But it's going to pollute the user_meta table if you're dealing with tons of content or a network install. – editor Mar 18 '11 at 1:33
See update (some filler text) – kaiser Mar 18 '11 at 16:45
Thanks for the reply. I'm not the greatest at PHP so I'm at a loss as to how to get started with this. – Micanio Mar 20 '11 at 19:59
@Micanio: Sry to say, but in this case it might be better off, if you hire someone. – kaiser Mar 21 '11 at 0:22
@kaiser: I've had a go at knocking something up but can't seem to get it to work still. Any chance you could have a quick look? Thanks in advance for any help. – Micanio Mar 21 '11 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.