PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Dynamic CCAP

s2Member Plugin. A Membership plugin for WordPress®.

Dynamic CCAP

Postby flxmeister » February 20th, 2011, 12:03 pm

hi guys,

i need to make the ccap query dynamic. instead of having the static

<?php if (current_user_can("access_s2member_ccap_xyz")){ ?>


i need something like

<?php if (current_user_can("access_s2member_ccap_USERNAME")){ ?>

i do not know how to integrate the <?php echo S2MEMBER_CURRENT_USER_LOGIN; ?> query.

anyone any ideas? thanks for your help!


flo
User avatar
flxmeister
Registered User
Registered User
 
Posts: 6
Joined: September 23, 2010

Re: Dynamic CCAP

Postby Cristián Lávaque » February 21st, 2011, 11:42 am

You can try this

Code: Select all
'access_s2member_ccap_' . S2MEMBER_CURRENT_USER_LOGIN
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Dynamic CCAP

Postby flxmeister » February 22nd, 2011, 5:09 pm

great! works:

Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>
             
             Some premium content for all Level 1 Members.
         
             <?php if (current_user_can("access_s2member_ccap_" . S2MEMBER_CURRENT_USER_LOGIN)){ ?>
                 Display links for music as well. 
             <?php } ?>
             
             <?php if (current_user_can("access_s2member_ccap_videos")){ ?>
                 Display videos as well.
             <?php } ?>
         
         <?php } else { ?>
             Some public content.
         <?php } ?>


but instead of showing a static text line i'd like to insert a query. doenst work ;( any idea what is wrong by simply inserting

Code: Select all
<?php while (have_posts()) : the_post(); ?>
            
        <div id="post-<?php the_ID(); ?><?php post_class(); ?>>
            <div class="post-header">
                <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
                <p>by <?php the_author(); ?> on <?php the_time('F j, Y') ?></p>
            </div>
            
            <?php the_excerpt(); ?>
            
            <div class="post-meta">
                <ul>
                    <li><?php comments_popup_link('Leave your comment', 'One comment', '% comments'); ?><?php the_tags(' &bull; Tagged as: ', ', ', ''); ?></li>
                    <li>Share on <a href="http://twitter.com/home?status=Currently reading: <?php the_title_attribute(); ?> <?php the_permalink(); ?>">Twitter</a>, <a href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>&amp;t=<?php the_title_attribute(); ?>">Facebook</a>, <a href="http://del.icio.us/post?v=4;url=<?php the_permalink(); ?>">Delicious</a>, <a href="http://digg.com/submit?url=<?php the_permalink(); ?>">Digg</a>, <a href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title_attribute(); ?>">Reddit</a></li>
                    <?php edit_post_link('Edit this post', '<li>', '</li>'); ?>
                </ul>
            </div>
        </div>

        <?php endwhile; ?>
        
        <?php if (show_posts_nav()) : ?>
        
        <div class="post-navigation">
            <ul>
                <li><?php next_posts_link('&laquo; Previous page') ?></li>
                <li><?php previous_posts_link('Next page &raquo;') ?></li>
            </ul>
        </div>
        
        <?php endif; ?>
        
    <?php else : ?>

    <h2 class="page-title">Nothing found</h2>
    <p>There are not posts belonging to this category or tag. Try searching below:</p>
    <?php get_search_form(); ?>
    
    <?php endif; ?>


insetad of static text? thanks!
User avatar
flxmeister
Registered User
Registered User
 
Posts: 6
Joined: September 23, 2010

Re: Dynamic CCAP

Postby Cristián Lávaque » February 22nd, 2011, 5:21 pm

Glad it worked.

Hmm... could you explain what you want to insert where? I'm not sure I understand what you're asking.

Try wrapping code blocks with the code tags to make them easier to read. ;)

[code=php]Your code goes here. [/code]
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Dynamic CCAP

Postby flxmeister » March 1st, 2011, 4:21 am

Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>

Some premium content for all Level 1 Members.

<?php if (current_user_can("access_s2member_ccap_" . S2MEMBER_CURRENT_USER_LOGIN)){ ?>
Display links for music as well.
<?php } ?>

<?php if (current_user_can("access_s2member_ccap_videos")){ ?>
Display videos as well.
<?php } ?>

<?php } else { ?>
Some public content.
<?php } ?>


Now. Instead of static text like
Display links for music as well
i'd like to insert some wp queries like

Code: Select all
<?php while (have_posts()) : the_post(); ?>

<div id="post-<?php the_ID(); ?><?php post_class(); ?>>
<div class="post-header">
<h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p>by <?php the_author(); ?> on <?php the_time('F j, Y') ?></p>
</div>

<?php the_excerpt(); ?>

<div class="post-meta">
<ul>
<li><?php comments_popup_link('Leave your comment', 'One comment', '% comments'); ?><?php the_tags(' &bull; Tagged as: ', ', ', ''); ?></li>
<li>Share on <a href="http://twitter.com/home?status=Currently reading: <?php the_title_attribute(); ?> <?php the_permalink(); ?>">Twitter</a>, <a href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>&amp;t=<?php the_title_attribute(); ?>">Facebook</a>, <a href="http://del.icio.us/post?v=4;url=<?php the_permalink(); ?>">Delicious</a>, <a href="http://digg.com/submit?url=<?php the_permalink(); ?>">Digg</a>, <a href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title_attribute(); ?>">Reddit</a></li>
<?php edit_post_link('Edit this post', '<li>', '</li>'); ?>
</ul>


Unfortunately i can't get this to work.

any idea? thank you so much! flo
User avatar
flxmeister
Registered User
Registered User
 
Posts: 6
Joined: September 23, 2010

Re: Dynamic CCAP

Postby Cristián Lávaque » March 1st, 2011, 12:14 pm

Wouldn't it be something like this?

Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>

    Some premium content for all Level 1 Members.

    <?php if (current_user_can("access_s2member_ccap_" S2MEMBER_CURRENT_USER_LOGIN)){ ?>

        <?php while (have_posts()) : the_post(); ?>

        <div id="post-<?php the_ID(); ?><?php post_class(); ?>>
        <div class="post-header">
        <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
        <p>by <?php the_author(); ?> on <?php the_time('F j, Y'?></p>
        </div>

        <?php the_excerpt(); ?>

        <div class="post-meta">
        <ul>
        <li><?php comments_popup_link('Leave your comment''One comment''% comments'); ?><?php the_tags(' &bull; Tagged as: '', '''); ?></li>
        <li>Share on <a href="http://twitter.com/home?status=Currently reading: <?php the_title_attribute(); ?> <?php the_permalink(); ?>">Twitter</a>, <a href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>&amp;t=<?php the_title_attribute(); ?>">Facebook</a>, <a href="http://del.icio.us/post?v=4;url=<?php the_permalink(); ?>">Delicious</a>, <a href="http://digg.com/submit?url=<?php the_permalink(); ?>">Digg</a>, <a href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title_attribute(); ?>">Reddit</a></li>
        <?php edit_post_link('Edit this post''<li>''</li>'); ?>
        </ul>
        </div>
        </div>

        <?php endwhile; ?>

    <?php ?>

    <?php if (current_user_can("access_s2member_ccap_videos")){ ?>
        Display videos as well.
    <?php ?>

<?php } else { ?>
    Some public content.
<?php ?>
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

cron