function memberful_wp_protect_content($content)
{
    global $post;
    if (current_user_can('publish_posts')) {
        return $content;
    }
    if (!memberful_can_user_access_post(wp_get_current_user()->ID, $post->ID)) {
        $memberful_marketing_content = memberful_marketing_content($post->ID);
        return apply_filters('memberful_wp_protect_content', $memberful_marketing_content);
    }
    return $content;
}
Exemple #2
0
function memberful_wp_metabox($post)
{
    wp_nonce_field(plugin_basename(__FILE__), 'memberful_nonce');
    $view_vars = array();
    $entities = array(Memberful_Post_ACL::DOWNLOAD, Memberful_Post_ACL::SUBSCRIPTION);
    foreach ($entities as $entity) {
        $acl_manager = new Memberful_Post_ACL($entity);
        $view_vars[$entity . 's'] = memberful_wp_metabox_acl_format($acl_manager->get_acl($post->ID), $entity);
    }
    $marketing_content = array_filter(array(memberful_marketing_content($post->ID), memberful_wp_default_marketing_content(), memberful_wp_marketing_content_explanation()));
    $view_vars['marketing_content'] = reset($marketing_content);
    $view_vars['viewable_by_any_registered_users'] = memberful_wp_get_post_available_to_any_registered_users($post->ID);
    memberful_wp_render('metabox', $view_vars);
}