latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Displaying Links Based on Capabilities

Home Forums Community Forum Displaying Links Based on Capabilities

This topic contains 2 replies, has 2 voices. Last updated by  Eduan 4 years, 2 months ago.

Topic Author Topic
Posted: Tuesday Nov 6th, 2012 at 11:44 pm #30843
Joy Vuijk
Username: joyvuijk

I would like to be able to display links based on the custom capabilities assigned to a user.

I am currently using this code to create a menu on a page and using a plugin that allows php inside posts and pages.

Though the links are displaying, it is displaying all links to all users no matter the custom capabilities assigned to the account. Since they do not have access to the content when they click on a link they see the “access denied” page.

How can I set it up so that they only see what they have access to?

<ul>
<?php if (current_user_can("access_s2member_ccap_hbs")){ ?>
        <li>[wpfilebase tag=file id=1137 tpl=simple /]</li>
    <?php } ?>
    
<?php if (current_user_can("access_s2member_ccap_sbs")){ ?>
        <li>[wpfilebase tag=file id=1197 tpl=simple /]</li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_h1r")){ ?>
        <li><a title="House First Reading" href="http://alrrs.com/reports/house-first-reading/">House First Readings</a></li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_s1r")){ ?>
        <li><a title="Senate First Reading" href="http://alrrs.com/reports/senate-first-reading/">Senate First Readings</a></li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_h2r")){ ?>
        <li><a title="House Second Reading" href="http://alrrs.com/reports/house-second-reading/">House Second Readings</a></li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_s2r")){ ?>
        <li><a title="Senate Second Reading" href="http://alrrs.com/reports/senate-second-reading/">Senate Second Readings</a></li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_cma")){ ?>
        <li>[wpfilebase tag=file id=1179 tpl=simple /]</li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_lrr")){ ?>
        <li>[wpfilebase tag=file id=1172 tpl=simple /]</li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_scr")){ ?>
        <li>[wpfilebase tag=file id=1196 tpl=simple /]</li>
    <?php } ?>

<?php if (current_user_can("access_s2member_ccap_like")){ ?>
        <li>[wpfilebase tag=file id=1198 tpl=simple /]</li>
    <?php } ?>

</ul>

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Tuesday Nov 6th, 2012 at 11:56 pm #30845
Joy Vuijk
Username: joyvuijk

I was able to resolve my own issue by using short codes rather than php.

Posted: Wednesday Nov 7th, 2012 at 8:15 am #30877
Eduan
Username: Eduan
Moderator

Glad you solved your problem Joy. :)

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.