WordPress.org

Forums

Need a little help with this code (force login) (1 post)

  1. yortem
    Member
    Posted 1 year ago #

    i have this code that force id post to login.

    function my_force_login() {
    global $post;
    
    if (!is_single()) return;
    
    $ids = array(188, 185, 171); // array of post IDs that force login to read
    
    if (in_array((int)$post->ID, $ids) && !is_user_logged_in()) {
    auth_redirect();
    }
    }

    how i can i change this instead of 188,185,171 - to all ids that i have in my site? or all posts from category?

Topic Closed

This topic has been closed to new replies.

About this Topic