Easy Digital Downloads is the perfect WordPress plugin for those who are selling digital and other non-physical products using WordPress. It is not bloated with features, instead it only comes with the features most users will definitely need, as stated in the plugin description:

Rather than attempting to provide every feature under the sun, Easy Digital Downloads makes selling digital simple and complete by providing just the features you need.

So in this tutorial we’ll cover one of those features that are not vital to the plugin but useful for some users to have. To be more specific we’ll focus on the comments.

This will be a series of tutorials and in this first part of the series we’ll enable comments and add “purchased” and “author” badges.

Enabling Comments

By default comments functionality is not activated for EDD downloads. EDD comes with a filter named edd_download_supports which allows us to change which WordPress features are supported by the custom post type added by EDD.

Author Badge

Another useful badge to display would be on the comments made by the owner/author of the download. For that we will need to check if the ID of the user who left the comment is the same as the user who owns the download.

We already have the user ID ( $commenter_id ) and we just need to get the author id using get_the_author_meta().

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

functionmyprefix_comment_badges($return,$author,$comment_ID){

// make sure we only proceed if we are in the comments listing on a download page

And that is our final code which displays “purchased” and “author” badges. You’ll of course need some CSS to style the badges and CSS is not what this tutorial is about but here’s what you could use:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

.badge-purchased,

.badge-author {

margin-left:10px;

font-size:80%;

padding:3px5px;

color:#fff;

}

.badge-purchased {

background:#33bc5d;

}

.badge-author {

background:#337abc;

}

Final Words

That’s all for part 1 of this tutorial series.

In part 2 we will be going over restricting the access to viewing and making comments based on whether the current user has purchased the download. If you’re interested in that make sure to subscribe to our newsletter ( form in the sidebar ) and we’ll let you know once it’s published.

If you liked this article/tutorial please consider sharing it on Twitter or Facebook, it would be of great help.

Comments

This is just what I was looking for, to turn on comments…but being that I am no coder, I am unfamiliar with WHERE to put this code. Can you please tell me what file and where I should be putting this in the file? Thank you for helping a total novice! 🙂