Open kristineds opened 8 years ago
Awesome idea for a KB Article! I've been meaning to draft something like this for a long time. I'm glad you beat me to it! :-)
Here's some initial feedback:
I suggest not using something as generic as books
for the Custom Capability. The title of this KB Article says "ebooks", i.e., more than one ebook, but all the examples here seem to explain how to provide access to one thing (books
) and not multiple things (book1
, book2
, etc.).
I suggest using an example where someone wants to sell two separate ebooks (book1
and book2
) and then explain how you can create a page for eBook 1 and another page for eBook 2. Then you could explain how /s2member-files/access-s2member-ccap-book1/
would contain all of the materials related to eBook 1 (e.g., PDF version of the ebook, Kindle version of the ebook, etc.).
A multiple eBooks example like this is likely to be far more common than someone just wanting to provide access to "all of their ebooks" via a single books
Custom Capability. They're more likely to want to sell various ebooks, where people could buy one ebook, then come back and buy another later.
There are actually two ways to do this:
Both approaches have their pros and cons. The Specific Post/Page method is easier (for both the site owner and for the person purchasing access), however the Membership Level Access + Custom Capability method is more flexible and allows the site owner to collect the email address of the person purchasing. It also allows the site owner to keep track of how many ebooks each person has purchased and even expand the site in other ways going forward (e.g., they might decide later to add a discussion forum to their site--then all the existing users who purchased ebooks can use their existing account to gain access to the forum; if they used Specific Post/Page access, there would be no existing accounts and anyone who wanted to access the forum would then have to create an account).
There is actually a lot to the use case and I suggest changing this to a Tutorial and calling it "Selling eBooks with s2Member".
Absolutely!
Many of us are selling ebooks and the Website/Membership was an afterthought (prompted by friends/family) and a great idea.
@kristineds
Create a new page and add the text books to the Custom Capabilities restriction.
In addition to Raam's comments, a screenshot after this statement would be helpful.
KB Article Creation Checklist
draft
and eitherquestions
ortutorials
draft
label, adddraft-finalized
label)draft-finalized
label, addpending
)pending
label, addpublished
label)Introduction
See: s2Member → API/Scripting → Custom Capabilities (Packages) To learn more about custom capabilities, see this article
Step 1: Restrict content
Create a new page and add the text
books
to the Custom Capabilities restriction.If you want to create a separate WordPress Page for each book, you can simply restrict each Book Page to the
books
Custom Capability, and then only users with thebooks
Custom Capability will have access to those pages.Step 2: Generate shortcode for [Payment Gateway] button
When generating the [Payment Gateway] button, add the necessary Custom Capabilities (e.g.,
books
) to the generator before clicking the Generate Shortcode button. Otherwise, you should make sure that theccaps=""
attribute in the shortcode contains the Custom Capabilities that the new user should have assigned to their account after purchasing.Step 3: Add the code below on the newly created page from Step1.
(This includes the shortcode for the [Payment Gateway] button generated from Step 2)
Step 4: Restrict files based on custom capabilities
Create Custom Capability Sub-directories under:
/wp-content/plugins/s2member-files
. For the Custom Capability books, you can place protected files that should ONLY be accessible to Members withaccess_s2member_ccap_books
, inside:/s2member-files/access-s2member-ccap-books/
So the protected file would look something like this:
/s2member-files/access-s2member-ccap-books/KDP_book.pdf
See also: