Can't figure out exactly how to change user role for this snippet of PHP

Hi! I'm working on a client site and the past developer put in a snippet of php that basically only shows the page to certain user roles. I found the snippet of PHP where they did this, but I can't figure out exactly how to change the user role that will allow the user to view the content below it.

My client wants the content below this snippet to be shown to everyone (even guests not logged in) I tried a few things including just deleting the snippet but it was not working.

<!-- Check to see if user role is Premium Student, then shows content -->
		 <?php if (in_array("premium_student", $user_roles) ) { ?>

If you need more context, here is the entire php file:

<?php
/**
 *
 * This is the template for the Animations CPT.
 *
 * @package OPM
 */

get_header(); ?>
<?php
	// Gets User Role Info To Check Against
	$current_user = new WP_User(wp_get_current_user()->id);
	$user_roles = $current_user->roles;
?>

<div class="content-wrapper">

<div class="row">
	<div id="primary" class="site-content small-12 columns">
		<div id="content" role="main">

<div class="tac margin-bottom-3em no-hero-margin">
		<h1>Animations</h1>

<!-- Check to see if user role is PRemiujm Student, then shows content -->
		 <?php if (in_array("premium_student", $user_roles) ) { ?>

<?php 

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
  'post_type' => array('animations'),
  'post_status' => 'publish',
  'order' => 'ASC',
  'orderby' => 'title',
  'posts_per_page' => 9,
  'paged' => $paged,
);  

// WP_Query
$anim_query = new WP_Query( $args );

if ($anim_query->have_posts()) : // The Loop ?>

<!-- Starts layout of content -->
<ul class="small-block-grid-1 medium-block-grid-3">

<?php
	while ($anim_query->have_posts()): $anim_query->the_post();
?>

<?php $video_image = get_field( 'anim_video_image' ); ?>

<li class="video-item">
 <div class="video-container">

	<?php $video_thumb = get_field( 'anim_video_image' ); ?>
	<?php $video_url = get_field('anim_video_url'); ?>

	<a href="<?php echo $video_url; ?>" class="video-popup">
		<img src="<?php echo $video_thumb['sizes']['video-thumb']; ?>" alt="<?php echo $video_thumb['alt'];?>">
		<i class="fa fa-play-circle"></i>
	</a>

	</div><!-- /.video-container -->
	<div class="video-title"><?php the_title() ;?></div><!-- /.video-title -->
</li>

<?php endwhile; wp_reset_query(); ?>
</ul>
<!-- PUT PAGINATION CONTROLS HERE -->

<?php endif; ?>

<!-- If not a premium student, then show this message -->
<?php }else{ ?>
	<div class="not-premium-message">
		This content is avaialbe only for premium students. Purchase a premium course or course set to gain access.
	</div><!-- /.not-premium-message -->
<?php } ?>

</div>
		</div><!-- /.landing-content -->
	</div><!-- /.small-12 columns -->
</div><!-- /.row -->

<?php get_footer(); ?>
  • Nahid

    Hey Curran !
    Hope you are having a great day!

    Could you please try replacing the entire code in the .php file with the following (please make sure the existing code is backed up before the replacement)?

    <?php
    /**
     *
     * This is the template for the Animations CPT.
     *
     * @package OPM
     */
    
    get_header(); ?>
    
    <div class="content-wrapper">
    
    <div class="row">
    	<div id="primary" class="site-content small-12 columns">
    		<div id="content" role="main">
    
    <div class="tac margin-bottom-3em no-hero-margin">
    		<h1>Animations</h1>
    
    <?php 
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
      'post_type' => array('animations'),
      'post_status' => 'publish',
      'order' => 'ASC',
      'orderby' => 'title',
      'posts_per_page' => 9,
      'paged' => $paged,
    );  
    
    // WP_Query
    $anim_query = new WP_Query( $args );
    
    if ($anim_query->have_posts()) : // The Loop ?>
    
    <!-- Starts layout of content -->
    <ul class="small-block-grid-1 medium-block-grid-3">
    
    <?php
    	while ($anim_query->have_posts()): $anim_query->the_post();
    ?>
    
    <?php $video_image = get_field( 'anim_video_image' ); ?>
    
    <li class="video-item">
     <div class="video-container">
    
    	<?php $video_thumb = get_field( 'anim_video_image' ); ?>
    	<?php $video_url = get_field('anim_video_url'); ?>
    
    	<a href="<?php echo $video_url; ?>" class="video-popup">
    		<img src="<?php echo $video_thumb['sizes']['video-thumb']; ?>" alt="<?php echo $video_thumb['alt'];?>">
    		<i class="fa fa-play-circle"></i>
    	</a>
    
    	</div><!-- /.video-container -->
    	<div class="video-title"><?php the_title() ;?></div><!-- /.video-title -->
    </li>
    
    <?php endwhile; wp_reset_query(); ?>
    </ul>
    <!-- PUT PAGINATION CONTROLS HERE -->
    
    <?php endif; ?>
    
    </div>
    		</div><!-- /.landing-content -->
    	</div><!-- /.small-12 columns -->
    </div><!-- /.row -->
    
    <?php get_footer(); ?>

    The above mentioned code is just a copy of the one you provided with just the user role checks and conditionals removed so that the content can be viewed publicly.

    Hope this helps. Let us know if this works for you. Thanks!

    Kind regards,
    Nahid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.