Support

Account

Home Forums General Issues How to prevent non-members from viewing my post

Unread

How to prevent non-members from viewing my post

  • Hi, I have a movie website that shows the post to all visitors and members on front page. I have set it so that only members can watch the movies, but I want when visitors clicks the play button to watch it from front page, it will re-direct them to register page.

    The website is http://www.mysaftv.com

    I have this code to use on the template. I don’t know exactly which place to place it. I have both single-video.php and single.php.

    Below is the code:

    $post = get_queried_object();

    if ( function_exists( ‘pmpro_has_membership_access’ ) ) {

    // Check if the user has access to the post.
    $hasaccess = pmpro_has_membership_access( $post->ID );

    // Display Advanced Custom Fields if the user has access to the post.
    if( ! empty( $hasaccess ) && function_exists( ‘get_field’ ) ) {

    if ( get_field( ‘test_field_1’ ) ) {
    the_field( ‘test_field_1’ );
    }

    if ( get_field( ‘test_field_2’ ) ) {
    the_field( ‘test_field_2’ );
    }
    }
    }

    I need help to configure ACF correctly in other to achieve this goal. Presently, both visitors and members can watch it without restriction, but I want on clicking play button, let non-members be taken to custom page.

    Kindly assist me on this.

    Thanks.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.