function memberaccess_manage_users_custom_column($content, $column_name, $user_id) { if ($column_name != 'member-access') { return; } $terms = get_terms('acp-access-level', array('hide_empty' => false)); if (!$terms) { return ''; } $output = ''; foreach ((array) $terms as $term) { if (!member_has_access_level($term->term_id, $user_id)) { continue; } $output .= esc_html($term->name) . '<br />'; } return $output; }
function accesspress_segmented_content($atts, $has_access = '', $no_access = '', $check_delay = false) { $atts = shortcode_atts(array('accesslevel' => '', 'delay' => '0'), $atts); // show no access content unless we have an access level & the user is logged in if (empty($atts['accesslevel']) || !is_user_logged_in()) { return ''; } $delay = $check_delay ? (int) $atts['delay'] : 0; if (member_has_access_level($atts['accesslevel'], 0, $delay)) { return $has_access; } return $no_access; }
function premise_has_content_access() { global $post; if (!premise_is_protected_content()) { return true; } // if it's not published let WP handle permissions if ($post->post_status == 'draft' && 'true' == $_GET['preview']) { return true; } // don't let visitors access protected content if (!is_user_logged_in()) { return false; } $user = wp_get_current_user(); $cap = 'edit_other_' . ('page' == $post->post_type ? 'post' : $post->post_type) . 's'; if ($user->ID == $post->post_author || current_user_can($cap)) { return true; } $access_level = get_post_meta($post->ID, '_acp_access_levels', true); $protected = accesspress_get_custom_field('_acp_protection'); if (member_has_access_level($access_level)) { if ('member' == $protected) { return true; } } elseif ('nonmember' == $protected) { return true; } return false; }
function post_content_filter($content) { global $post; $protected = accesspress_get_custom_field('_acp_protection'); if (!$protected) { return $content; } // close comments on protected content add_filter('comments_open', '__return_false', 99); if ($post->post_status == 'draft' && 'true' == $_GET['preview']) { return $content; } if (!is_user_logged_in()) { return sprintf(__('Please <a href="%s">Log in</a> to view this content.', 'premise'), memberaccess_login_redirect(get_permalink())); } $user = wp_get_current_user(); $cap = 'edit_other_' . ('page' == $post->post_type ? 'post' : $post->post_type) . 's'; if ($user->ID == $post->post_author || current_user_can($cap)) { return $content; } $access_level = get_post_meta($post->ID, '_acp_access_levels', true); if (member_has_access_level($access_level)) { if ('member' == $protected) { return $content; } } elseif ('nonmember' == $protected) { return $content; } return ''; }