Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter watchdogs2

    (@iplus4u)

    Hello,

    I just checked the configuration and everything is saved there. Also I tried another themes and disabling some possible conflicting plugins but nothing changes. All the values are still showing 0. Is there anyway I can send you the debug file?

    Thanks!

    Thread Starter watchdogs2

    (@iplus4u)

    Thank you for your reply, would you mind letting me know which css file you were talking about? I’m fairly new to Woo and not sure where to find it

    @trav

    Hello,

    The cron job ran for me, and it did put expired members to ‘expire’ status. But there seem to be no function to handle these members. That might be the reason causes the problem

    Thread Starter watchdogs2

    (@iplus4u)

    Just a quick note, the cron job actually ran and put the expired members to the correct status, but it only runs once a day.

    Thread Starter watchdogs2

    (@iplus4u)

    I’ve finally figured out the way to deal with expired users. Use this to place membership.php in shortcodes folder

    <?php
    /*
    	Shortcode to hide/show content based on membership level
    */
    function pmpro_shortcode_membership()
    {
        // First check if user is logged in
        if ( is_user_logged_in() )
        {
    
            // Checking enddate
            global $wpdb, $current_user;
            $enddate = $wpdb->get_col("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users");
            $now = current_time('timestamp');
    
            // Expired or not?
            if($enddate < $now)
                return do_shortcode($content);
            else
    		{
    			$text = <<<HTML
    		<p style="text-align: center;"><strong>This content is for Premium members only</strong></p>
    HTML;
    			return $text;	//just hide it
    		}
        }
    
        // if not logged in OR logged-in but doesn't have a membership level
        	{
    			$text = <<<HTML
    		<p style="text-align: center;"><strong>This content is for Premium members onl</strong></p>
    HTML;
    			return $text;	//just hide it
    		}
    }
    add_shortcode("membership", "pmpro_shortcode_membership");

    Cheers!

    • This reply was modified 9 years, 5 months ago by watchdogs2.
    • This reply was modified 9 years, 5 months ago by watchdogs2.
    • This reply was modified 9 years, 5 months ago by watchdogs2.
    • This reply was modified 9 years, 5 months ago by watchdogs2.
    Thread Starter watchdogs2

    (@iplus4u)

    Thank you for the reply @andrewza

    From my active pmpro list, the member is there, even though with expiry date older than the current time. I checked the db as well and true enough the status is “active”. Is there anyway to active the cron?

    Using the cron plugin you suggested, I’m not seeing anything like that just yet. The restricted content can still be accessed using the expired account.

    Since I don’t know too much about coding, it would be really hard for me to modify the function of the shortcode. The one thing I can think of right now is adding something to deny access for members with $enddate < $now. But I don’t really know how to execute it. Here’s the full code for your reference:

    <?php
    /*
    	Shortcode to hide/show content based on membership level
    */
    function pmpro_shortcode_membership($atts, $content=null, $code="")
    {
    	// $atts    ::= array of attributes
    	// $content ::= text within enclosing form of shortcode element
    	// $code    ::= the shortcode found, when == callback name
    	// examples: [membership level="3"]...[/membership]
    
    	extract(shortcode_atts(array(
    		'level' => NULL,
    		'levels' => NULL,
    		'delay' => NULL
    	), $atts));
    
    	//if levels is used instead of level
    	if(isset($levels) && !isset($level))
    		$level = $levels;
    	
    	global $wpdb, $current_user;
    
    	//guilty until proven innocent :)
    	$hasaccess = false;
    
    	//figure out which level/levels to check
    	if(!empty($level) || $level === "0" || $level === 0)
    	{
    	   //they specified a level(s)
    	   if(strpos($level, ","))
    	   {
    		   //they specified many levels
    		   $levels = explode(",", $level);
    	   }
    	   else
    	   {
    		   //they specified just one level
    		   $levels = array($level);
    	   }	   
    	}
    	else
    	{
    		//didn't specify a membership level, so use false so pmpro_hasMembershipLevel checks for any level
    		$levels = false;
    	}
    
    	//check their level
    	if(pmpro_hasMembershipLevel($levels))
    		   $hasaccess = true;
    
    	//is there a delay?
    	if($hasaccess && !empty($delay))
    	{		
    		//okay, this post requires membership. start by getting the user's startdate
    		if(!empty($levels))
    			$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND membership_id IN(" . implode(",", $levels) . ") AND user_id = '" . $current_user->ID . "' ORDER BY id LIMIT 1";
    		else
    			$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . $current_user->ID . "' ORDER BY id LIMIT 1";
    
    		$startdate = $wpdb->get_var($sqlQuery);
    
    		//adjust start date to 12AM
    		$startdate = strtotime(date_i18n("Y-m-d", $startdate));
    
    		if(empty($startdate))
    		{
    			//user doesn't have an active membership level
    			$hasaccess = false;
    		}
    		else
    		{
    			//how many days has this user been a member?
    			$now = current_time('timestamp');
    			$days = ($now - $startdate)/3600/24;
    
    			if($days < intval($delay))
    				$hasaccess = false;	//they haven't been around long enough yet
    		}
    	}
    
    	//to show or not to show
    	//Edited with custom text for free members
    	if($hasaccess)
    		return do_shortcode($content);	//show content
    	else
    return "";	//just hide it
    	
    }
    add_shortcode("membership", "pmpro_shortcode_membership");
    
    • This reply was modified 9 years, 5 months ago by watchdogs2.
    • This reply was modified 9 years, 5 months ago by watchdogs2.
    Thread Starter watchdogs2

    (@iplus4u)

    The files I downloaded are also checked “Direct linking: Redirect to post”

    Thread Starter watchdogs2

    (@iplus4u)

    I unchecked the box “Accept empty referers”, but still I can download without referrer (copy link to the browser address bar)

    Increase the maximum memory allowed in your php setting should do the trick

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