Title: watchdogs2's Replies | WordPress.org

---

# watchdogs2

  [  ](https://wordpress.org/support/users/iplus4u/)

 *   [Profile](https://wordpress.org/support/users/iplus4u/)
 *   [Topics Started](https://wordpress.org/support/users/iplus4u/topics/)
 *   [Replies Created](https://wordpress.org/support/users/iplus4u/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/iplus4u/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/iplus4u/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/iplus4u/engagements/)
 *   [Favorites](https://wordpress.org/support/users/iplus4u/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Limit Comments and Word Count] Comment restriction doesn’t work](https://wordpress.org/support/topic/comment-restriction-doesnt-work/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/comment-restriction-doesnt-work/#post-10720909)
 * 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!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Product Specifications for Woocommerce] Weird spacing](https://wordpress.org/support/topic/weird-spacing/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/weird-spacing/#post-9185777)
 * 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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions] Restricted Access not Restricted!](https://wordpress.org/support/topic/restricted-access-not-restricted/)
 *  [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/restricted-access-not-restricted/#post-8520146)
 * [@trav](https://wordpress.org/support/users/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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions] Expired members still get access to [membership] protected content](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/#post-8520127)
 * 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.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions] Expired members still get access to [membership] protected content](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/#post-8517982)
 * 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](https://wordpress.org/support/users/iplus4u/).
    -  This reply was modified 9 years, 5 months ago by [watchdogs2](https://wordpress.org/support/users/iplus4u/).
    -  This reply was modified 9 years, 5 months ago by [watchdogs2](https://wordpress.org/support/users/iplus4u/).
    -  This reply was modified 9 years, 5 months ago by [watchdogs2](https://wordpress.org/support/users/iplus4u/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions] Expired members still get access to [membership] protected content](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/expired-members-still-get-access-to-membership-protected-content/#post-8515638)
 * Thank you for the reply [@andrewza](https://wordpress.org/support/users/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](https://wordpress.org/support/users/iplus4u/).
    -  This reply was modified 9 years, 5 months ago by [watchdogs2](https://wordpress.org/support/users/iplus4u/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Filebase Download Manager] About referrer](https://wordpress.org/support/topic/about-referrer/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/about-referrer/#post-4721466)
 * The files I downloaded are also checked “Direct linking: Redirect to post”
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Filebase Download Manager] About referrer](https://wordpress.org/support/topic/about-referrer/)
 *  Thread Starter [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/about-referrer/#post-4721464)
 * I unchecked the box “Accept empty referers”, but still I can download without
   referrer (copy link to the browser address bar)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Filebase Download Manager] Fatal Error in syncing – Out of Memory](https://wordpress.org/support/topic/fatal-error-in-syncing-out-of-memory/)
 *  [watchdogs2](https://wordpress.org/support/users/iplus4u/)
 * (@iplus4u)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-in-syncing-out-of-memory/#post-4632802)
 * Increase the maximum memory allowed in your php setting should do the trick

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