Page 1 of 1

List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 11:47 am
by webbmalin
I love you guys, you always help with my problems!
I promise that once my website is done and I'm more experienced I will help others too.

So, I have a custom post type called "kurs". (translates to class)

Every Parent kurs is visible for everybody, this is where the buy button will be.
The kurs will have childpages that are restricted to s2member Level 1 and also a custom capability.

I list the childpages in the sidebar.

I managed to show this sidebar only if you are logged in... BUT...
I want this sidebar (or the childpages) to only be visible if you paid for this custom capability...

And I don't want to write the name of the custom capability in the code, it shouldn't matter what cc is used.

I figured, maybe I should use "is_permitted_by_s2member" in some way, but I couldn't get it to work...

Can anyone help me with this one? :?

Thanks
/Malin

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 11:51 am
by Eduan
You could check this post:
viewtopic.php?p=56366#p56366

Bruce C shows conditionals but for Custom Capabilites.

Hope this helps. :)

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 11:53 am
by Bruce C
You need to use the PHP if statement for it:

Code: Select all
<?php
if (current_user_can('access_s2member_ccap_kurs'))
{
//This is where the widget goes
}
?>

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 12:11 pm
by webbmalin
Thanks!

But I do NOT want to write the cc in the code. (kurs is the post type btw, the cc is called "medierna")
I need it to work even if my client adds more custom capablities...

I mean I can show child pages for current page even without writing the page ID... should be possible to show current (or accessable) custom capabilities without writing the name of it... or am I totally out of it ??? :)

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 1:15 pm
by Bruce C
I'm sure it's possible.

You'd probably have to run a loop through the get_post_meta function to check for the s2member entry, and check to see what custom capabilities is has. I'm not sure how to do it by just talking about it, but I can probably write a code to do this.

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 1:29 pm
by webbmalin
Alright... yeah it's outside my knowledge, haha...
I don't really know php and stuff, only html and learned some wordpress functions that I reuse,,,, but I guess you could tell :)

If you come up with a code that works, you're an angel !!!

Re: List childpages only if custom capability is paid for

PostPosted: December 12th, 2011, 1:33 pm
by Bruce C
OK, I'll see if I can throw something together

Re: List childpages only if custom capability is paid for

PostPosted: December 19th, 2011, 8:38 am
by webbmalin
Hi Bruce!
This is the last thing left on my project :)
I'd really like to get this done, but I just can't figure out how.
I'm realizing this is not a common question, and of course I can pay you for this. Should I send my request using that form on your website, or can we just email each other? malin @ webbmalin.se

Thanks,
Malin

Re: List childpages only if custom capability is paid for

PostPosted: December 19th, 2011, 10:51 am
by Eduan
Hi webbmalin,
could you please send a request using that form?
It's our standard way of handling jobs.