• 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?

The topic ‘Need a little help with this code (force login)’ is closed to new replies.