# Members-Only Content After the "More" Tag

> Shows visitors everything above the "More" block of a post and keeps the rest for logged-in members, with a login prompt where the content stops.

- Type: PHP
- Runs: Run everywhere
- Category: [Memberships](https://wpide.com/library/category/memberships/)
- Tags: members, teaser, content
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/members-only-after-more-tag/

## Code

```php
// Category slugs to apply this to; leave empty for all posts.
$wpide_more_categories = array();

add_filter( 'the_content', function ( $content ) use ( $wpide_more_categories ) {
    if ( is_user_logged_in() || ! is_singular( 'post' ) || ! in_the_loop() ) {
        return $content;
    }

    $raw = get_post_field( 'post_content', get_the_ID() );

    if ( false === strpos( $raw, '<!--more' ) || ( $wpide_more_categories && ! has_category( $wpide_more_categories ) ) ) {
        return $content;
    }

    $parts  = get_extended( $raw );
    $teaser = apply_filters( 'wpide_members_more_teaser', do_blocks( $parts['main'] ) );

    $box = '<div class="wpide-members-only"><p>The rest of this post is for members. <a href="' . esc_url( wp_login_url( get_permalink() ) ) . '">Log in</a>';

    if ( get_option( 'users_can_register' ) ) {
        $box .= ' or <a href="' . esc_url( wp_registration_url() ) . '">join for free</a>';
    }

    return wp_kses_post( wpautop( $teaser ) ) . $box . ' to keep reading.</p></div>';
}, 1 );
```

## Notes

Only posts that contain a More block (or <!--more-->) are affected. Limit it to some categories with $wpide_more_categories.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Members-Only Content After the "More" Tag" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
