Beispiel #1
0
function rcp_redirect_from_premium_post() {
	global $rcp_options, $user_ID, $post;
	if( isset($rcp_options['hide_premium'] ) && $rcp_options['hide_premium'] ) {
		if( !rcp_is_active( $user_ID ) && is_singular() && rcp_is_paid_content( $post->ID ) ) {
			if( isset( $rcp_options['redirect_from_premium'] ) ) {
				$redirect = get_permalink( $rcp_options['redirect_from_premium'] );
			} else {
				$redirect = home_url();
			}
			wp_redirect( $redirect ); exit;
		}
	}
}
Beispiel #2
0
/**
 * Check if current post is locked and if user has access to current content.
 *
 * @return bool
 */
function stag_rcp_user_has_no_access()
{
    if (!stag_is_rcp_active()) {
        return false;
    }
    global $post, $user_ID, $rcp_options;
    $access_level = get_post_meta($post->ID, 'rcp_access_level', true);
    if (rcp_is_paid_content($post->ID)) {
        if (!rcp_is_paid_user($user_ID) || !rcp_user_has_access($user_ID, $access_level) && $access_level > 0) {
            return true;
        }
    }
    return false;
}
function rcp_filter_feed_posts($content)
{
    global $rcp_options;
    if (!is_feed()) {
        return $content;
    }
    $hide_from_feed = get_post_meta(get_the_ID(), 'rcp_hide_from_feed', true);
    if ($hide_from_feed == 'on') {
        if (rcp_is_paid_content($post_id)) {
            return rcp_format_teaser($rcp_options['paid_message']);
        } else {
            return rcp_format_teaser($rcp_options['free_message']);
        }
    }
    return do_shortcode($content);
}
 /**
  * Determines if the member can access current content
  *
  * @access  public
  * @since   2.1
  */
 public function can_access($post_id = 0)
 {
     $subscription_levels = rcp_get_content_subscription_levels($post_id);
     $access_level = get_post_meta($post_id, 'rcp_access_level', true);
     $sub_id = $this->get_subscription_id();
     // Assume the user can until proven false
     $ret = true;
     if (rcp_is_paid_content($post_id) && $this->is_expired()) {
         $ret = false;
     }
     if (!empty($subscription_levels)) {
         if (is_string($subscription_levels)) {
             switch ($subscription_levels) {
                 case 'any':
                     $ret = !empty($sub_id) && !$this->is_expired();
                     break;
                 case 'any-paid':
                     $ret = $this->is_active();
                     break;
             }
         } else {
             if (in_array($sub_id, $subscription_levels)) {
                 $needs_paid = false;
                 foreach ($subscription_levels as $level) {
                     $price = rcp_get_subscription_price($level);
                     if (!empty($price) && $price > 0) {
                         $needs_paid = true;
                     }
                 }
                 if ($needs_paid) {
                     $ret = $this->is_active();
                 } else {
                     $ret = true;
                 }
             } else {
                 $ret = false;
             }
         }
     }
     if (!rcp_user_has_access($this->ID, $access_level) && $access_level > 0) {
         $ret = false;
     }
     if (user_can($this->ID, 'manage_options')) {
         $ret = true;
     }
     return apply_filters('rcp_member_can_access', $ret, $this->ID, $post_id, $this);
 }
<?php

/**
 * Template name: Testimonies
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package Primemovers
 */
while (have_posts()) {
    the_post();
    if (rcp_is_paid_content('')) {
        get_header('secure');
    } else {
        get_header();
    }
    ?>

				<?php 
    get_template_part('content', 'testimonies');
    ?>

			<?php 
}
// end of the loop.
?>

<?php 
function rcp_display_message_to_non_loggged_in_users($content)
{
    global $rcp_options, $post, $user_ID;
    $message = isset($rcp_options['free_message']) ? $rcp_options['free_message'] : '';
    $paid_message = isset($rcp_options['paid_message']) ? $rcp_options['paid_message'] : '';
    if (rcp_is_paid_content($post->ID)) {
        $message = $paid_message;
    }
    $user_level = get_post_meta($post->ID, 'rcp_user_level', true);
    $access_level = get_post_meta($post->ID, 'rcp_access_level', true);
    $has_access = false;
    if (rcp_user_has_access($user_ID, $access_level)) {
        $has_access = true;
    }
    if (!is_user_logged_in() && ($user_level == 'Administrator' || $user_level == 'Editor' || $user_level == 'Author' || $user_level == 'Contributor' || $user_level == 'Subscriber') && $has_access) {
        return rcp_format_teaser($message);
    }
    // return the content unfilitered
    return $content;
}
 /**
  * Determines if the member can access current content
  *
  * @access  public
  * @since   2.1
  */
 public function can_access($post_id = 0)
 {
     $subscription_levels = rcp_get_content_subscription_levels($post_id);
     $access_level = get_post_meta($post_id, 'rcp_access_level', true);
     // Assume the user can until proven false
     $ret = true;
     if (rcp_is_paid_content($post_id) && !$this->is_active()) {
         $ret = false;
     }
     if (!rcp_user_has_access($this->ID, $access_level) && $access_level > 0) {
         $ret = false;
     }
     if (!empty($subscription_levels)) {
         if (!in_array($this->get_subscription_id(), $subscription_levels) && !user_can($this->ID, 'manage_options')) {
             $ret = false;
         }
     }
     return apply_filters('rcp_member_can_access', $ret, $this->ID, $post_id, $this);
 }
/**
 * Checks to see if content is restricted in any way.
 *
 * @since  2.5
 * @param  int $post_id The post ID to check for restrictions.
 * @return bool True if the content is restricted, false if not.
 */
function rcp_is_restricted_content($post_id)
{
    if (empty($post_id) || !is_numeric($post_id)) {
        return false;
    }
    $restricted = false;
    $post_id = absint($post_id);
    if (!$restricted && rcp_is_paid_content($post_id)) {
        $restricted = true;
    }
    if (!$restricted && rcp_get_content_subscription_levels($post_id)) {
        $restricted = true;
    }
    if (!$restricted) {
        $rcp_user_level = get_post_meta($post_id, 'rcp_user_level', true);
        if (!empty($rcp_user_level) && 'All' !== $rcp_user_level) {
            $restricted = true;
        }
    }
    if (!$restricted) {
        $rcp_access_level = get_post_meta($post_id, 'rcp_access_level', true);
        if (!empty($rcp_access_level) && 'None' !== $rcp_access_level) {
            $restricted = true;
        }
    }
    return apply_filters('rcp_is_restricted_content', $restricted, $post_id);
}