• Hi. I am working on a site using the Prosto theme. It is a site that sells subscriptions to videos. Here is a link: https://www.vjortho.com

    I need to add a piece of code to the loop that will send a paid subscriber directly to the full length video if he/she has already subscribed to that video, otherwise they go to the regular “synopsis’ page

    The “synopsis” page is here:
    https://www.vjortho.com/2010/12/computer-assisted-subtalar-arthrodesis/
    The “full length” page is here:
    https://www.vjortho.com/videos/video.cfm?vid=1033

    I wrote this code:

    // Custom funcion to forward user directly to full video if is a registered subscriber to that video
    
    $videoid = get_post_meta($post->ID, 'Catalog Number', true);
    
    function Streaming($videoid)
    {
    	if(isset($_COOKIE['subscription']))
    	{
    		if (in_array("streaming", $_COOKIE['subscription']) || (in_array($videoid, $_COOKIE['subscription']))
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}
    }	
    
    $validUser = Streaming($videoid);
    
    $vidlink = "https://www.vjortho.com/videos/video.cfm?vid=" . $videoid;
    
    // END forwarding function

    … and added a call to it here (in bold):

    <div id="post-<?php the_ID(); ?>" <?php post_class($portfolioclass); ?>><?php if ( !is_single()  ) {if ($portlayout != '2' ) {?><h5 class="entry-title"><a href="<?php if($lightbox !='' && $link !='') { echo $link;} <strong>elseif($validUser == true) {echo $vidlink; }</strong> else { the_permalink(); } ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'prosto' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php prosto_the_title_limited(18); ?></a></h5><?php } ?>

    but when I saved it to the loop, the site broke (nothing would display). So, if any one has an idea as to where I went wrong, please drop me a hint. ps: I know the cookie is set and working, it is just this side of it that is giving me fits).

  • The topic ‘Using a cookie within the Loop’ is closed to new replies.