/** * Denies/Allows access to view post content depending on whether a user has permission to view the content. * * @since 0.1.0 * @param string $content The content of a post. * @param string $content The content of a post or an error message. */ function members_content_permissions_protect($content) { /* If the current user can view the post, return the post content. */ if (members_can_current_user_view_post(get_the_ID())) { return $content; } /* Return an error message at this point. */ return members_get_post_error_message(get_the_ID()); }
function limit_access($value, $post_id, $field) { if (!is_admin()) { $url = esc_url(get_permalink($post_id)); //If the user is in the sales section $url = strpos($url, 'sales'); if (!members_can_current_user_view_post($post_id)) { $value = members_get_post_error_message($post_id) . members_login_form_shortcode(); } else { if (members_can_current_user_view_post($post_id) && is_user_logged_in() && $field['name'] == 'content' && $url > 0) { $value = '<div class="loginout">' . wp_loginout(get_permalink($post_id), false) . '</div>' . $value; } } } return $value; }
/** * Denies/Allows access to view post content depending on whether a user has permission to * view the content. * * @since 0.1.0 * @access public * @param string $content * @return string */ function members_content_permissions_protect($content) { $post_id = get_the_ID(); return members_can_current_user_view_post($post_id) ? $content : members_get_post_error_message($post_id); }