Ask your WordPress questions! Pay money and get answers fast! (more info)

Grant some users access to a download WordPress


I need to grant some user access to a download, and they should find that download in their woocommerce profile, without assign them a downloadable product.
I've two alternative hypothesis.
Hypothesis A: I create a product that grant access to a file, and I want user 1-2-3 to find the file in their profile, but I don't want to gift the whole product, only let them download the file.
Hypothesis B: I simply upload a file, without linking it to a product, and I want user 1-2-3 to find the file in their profile.
How can I do that?

Answers (1)


gangesh answers:

As you said you need to grant 'SOME' users access to download

There is another Hypothesis.

You can create File field in user area using Advanced Custom fields with return type as URL. See attachment.

After that you need to create 'woocommerce' folder in your theme, if its not already, then inside that another folder 'myaccount', if not already.

Then you need to copy a file 'my-account.php' from woocommerce->templates->myaccount folder to myaccount folder in your theme.

Once copied, you can add code, as shown below, to your theme's my-account.php file


echo $user_id = 'user_'.get_current_user_id();

if( get_field('file11', $user_id) ): ?>


<a href="<?php the_field('file11', $user_id ); ?>" >Download File</a>


<?php endif; ?>

This will display a download link in My account area for every user.
You can upload file for any specific user and corresponding file will be displayed in their area.

Hope this helps.