How to restricted a page in wordpress. For example : user [without login] can see 5 of game list. [example.com/game/]
and after click ‘view more’, user must login/register and after that, user can access full/100 game list. [example.com/game/]
Anyone know to make it without plugin? thank you
You can do this pretty easily with a shortcode. Hook into
init
and add the shortcode in your hooked function.Then in your callback function, you can check to see if the user is logged in. If they are, show them the content. If not, show them a login message. You can do literally whatever you want here: check for user capabilities to show them the content (different “membership levels”), show them an entire login form. A simple example:
As a plugin.
Usage
Somewhere in your pages/posts:
May be a custom shortcode is useful
See this plugin http://wordpress.org/extend/plugins/restrictedarea
It is obsolete but you should use the code for your pourpose
First you need to add a custom meta box that allows you to mark the post as hidden.