There are a few ways you might put this together, but you could take a look at these functions in the first instance:
Thread Starter
yortem
(@yortem)
i dont know php. can you make this little function for me?
If you will not be coding at all, your best bet is to use a Membership plugin. There are several very good ones.
For example, try the WP-Members plugin. Once installed you can specify that certain pages/posts of your site can be viewed only by a logged-in member.
Thread Starter
yortem
(@yortem)
how can i choose all posts from an array?
this code worked but i need al ids.
http://www.wpbeginner.com/wp-tutorials/force-users-to-login-before-reading-posts-in-wordpress/
i dont want plugin
If that code works, why not use it – what is it you are struggling with?
Thread Starter
yortem
(@yortem)
it just for little id’s and i need al posts.
nvm i got it.
function my_force_login() {
global $post;
if (!is_user_logged_in()) {
auth_redirect();
}
}
and put
<?php my_force_login(); ?>
before header in single.php