posts ) ) { return false; } if ( get_queried_object_id() !== $login_page_id ) { return false; } foreach ( (array) $wp_query->posts as $queried_post ) { $queried_post_id = is_object( $queried_post ) ? $queried_post->ID : $queried_post; if ( (int) $queried_post_id !== $login_page_id ) { return false; } } return true; } // No page of our own sits behind the login URL, which is how login plugins that serve a // virtual page behave. Keep the exemption, but only while the request has not resolved to // real content of any kind. // // Unlike the branch above, a 404 stays exempt here on purpose. A login path that WordPress // cannot route is a 404 to the main query, so the login page itself arrives in that state; // refusing it would redirect the login page to itself, which is the loop from #154. return ! is_singular() && ! is_archive() && ! is_search() && ! is_home() && ! get_queried_object_id(); } /** * Blocks feed items if the user has selected the private feed feature. * * @since 0.2.0 * @access public * @param string $content * @return string */ function members_private_feed( $content ) { return members_is_private_feed() ? members_get_private_feed_message() : $content; } /** * Returns the private feed error message. * * @since 1.0.0 * @access public * @return string */ function members_get_private_feed_message() { return apply_filters( 'members_feed_error_message', members_get_setting( 'private_feed_error' ) ); } /** * Returns an error if the REST API is accessed by an unauthenticated user. * * @link https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#require-authentication-for-all-requests * @since 2.0.0 * @access public * @param object $result * @return object */ function members_private_rest_api( $result ) { if ( empty( $result ) && members_is_private_rest_api() && ! is_user_logged_in() ) { return new WP_Error( 'rest_not_logged_in', esc_html( apply_filters( 'members_rest_api_error_message', __( 'You are not currently logged in.', 'members' ) ) ), array( 'status' => 401 ) ); } return $result; } /** * Outputs an error message if a user attempts to access a site that they do not have * access to on multisite. * * @since 2.0.0 * @access public * @return void */ function members_ms_private_blog_die() { $blogs = get_blogs_of_user( get_current_user_id() ); $blogname = get_bloginfo( 'name' ); $message = __( 'You do not currently have access to the "%s" site. If you believe you should have access, please contact your network administrator.', 'members' ); if ( empty( $blogs ) ) wp_die( sprintf( $message, $blogname ), 403 ); $output = '

' . sprintf( $message, $blogname ) . '

'; $output .= sprintf( '

%s

', __( 'If you reached this page by accident and meant to visit one of your own sites, try one of the following links.', 'members' ) ); $output .= ''; wp_die( $output, 403 ); }