• Resolved jazfotodesign

    (@jazfotodesign)


    *Is there a way to display links by specific role or capabilities?*

    https://www.floridaicam.com/

    I have made user levels with User Role Editor

    I gave user role ‘Year1’ privileges to read and level_0 and ‘Year2’ privileges to read and level_1

    I’m using User Login Widget and I have edited the log out section to show links.

    I want to show different links to users at that specific role.

    This is the code where the links appear

    }else{
    
    	        global $userdata;
    
    	        if(isset($before_title)) echo $before_title;
    
    	    	echo "Welcome : ". $userdata->display_name;
    
    	        if(isset($after_title)) echo $after_title;
    
    		?>
    
    <form name="logoutform" id="logoutform" action="<?php echo site_url('wp-login.php?action=logout&redirect_to='.site_url('/index.php'), 'logout_post') ?>" method="post">
    
    	<ul><li><a href="https://www.floridaicam.org/student-access">myFICAM</a></li>
    
    <li><a href="https://www.floridaicam.com/calendar">Academic Calender</a></li>
    <br><br>
    	<li><a href="<?php echo wp_logout_url(site_url('index.php'));?>">LogOut</a></li></ul>
    
    </form>

    and this is the code I tried inserting where the break tags are but it shot out an error.

    <?php
    if ( current_user_can( 'level_0' ) ) { ?>
    link
    <?php } ?>


    *Is there a way to display links by specific role or capabilities?*

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jazfotodesign

    (@jazfotodesign)

    or just show different content on same page to different levels

    Thread Starter jazfotodesign

    (@jazfotodesign)

    bump

    Thread Starter jazfotodesign

    (@jazfotodesign)

    ended up using,

    <?php
    if(current_user_can('level_0')) : ?>
    <div class="messages">
    level 0 content
    </div>
    <?php endif; ?>
    
    <?php
    if(current_user_can('level_1')) : ?>
    <div class="messages">
    level 0 content
    </div>
    <?php endif; ?>

    i used your code but it did not work…did you get a workaround ?

    Thread Starter jazfotodesign

    (@jazfotodesign)

    works fine, you will need user role editor to make user roles with just the levels you want, for example I made one with level_0 and level_1 as I only have 2 different types of roles. screenshot

    i’m working on plug-in for this to make user roles easily and shortcodes.

    <?php
    if(current_user_can('level_0')) : ?>
    level 0 content for user role 1
    <?php endif; ?>
    
    <?php
    if(current_user_can('level_1')) : ?>
    level 1 content for user role 2
    <?php endif; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display Link To Only Specific Role/Capability?’ is closed to new replies.