What is the best way to achieve unique Member functionality?
I have had success in providing member functionality using the s2Member plugin. There are several solutions available so I would recommend researching “membership” plugins.
I have had success in providing member functionality using the s2Member plugin. There are several solutions available so I would recommend researching “membership” plugins.
When you publish a post or page on WordPress you can set the status to Private. This means that this content is only viewable to registered and logged in users. You can then restrict files to the person who uploaded them (or disable upload for non-admin). Here is an example of how to do that. … Read more
You probably want pmpro_getMembershipLevelsForUser from functions.php: /* pmpro_getMembershipLevelsForUser() returns the membership levels for a user * * If $user_id is omitted, the value will be retrieved from $current_user. * By default it only includes active memberships. * * Return values: * Success returns an array of level objects. * Failure returns false. */ function pmpro_getMembershipLevelsForUser($user_id … Read more
The best way to have complete control is to use conditionals in your templates. Look at current_user_can() for specific permissions – or if its simply for being logged in you could use is_user_logged_in(). eg: if( is_user_logged_in() ){ // echo product details }else{ //echo login form and message } That we you have complete control over … Read more
Instead of forcing WordPress to have a custom membership system, if you want to use your own small membership feature, then you may not have to use sessions at all. For instance, if you want to password protect a specific set of pages, you could make one page require authentication, using a username and password … Read more
You can put this on your in your home page template or in your header.php (if you want to use across your entire site). <?php if ( !is_user_logged_in() ) { auth_redirect(); } ?> Details in the WordPress codex… https://codex.wordpress.org/Function_Reference/auth_redirect
My account staying logged when the browser closed
I would say plugins are very easy way to handle membership until unless you want it for a small scale like for few pages/posts etc. In that case you can register the level of users as per your requirements, assign capabilities and then on each page/post you can check if ( current_user_can() ) This can … Read more
The simplest method would be to create a single page and use a custom page template. For example, make a page with slug my-account. Then create a template and name it page-my-account.php. Then within that template, check if the user is logged in, and load their data if they are. if( is_user_logged_in() ){ $current_user = … Read more
Even if you’re skilled in “complex PHP websites” it’s safer to go with something that’s already built. If you code it yourself you’re very likely to overlook security issues and you’d have to constantly be updating it. It’s worth investing a bit of money in plugins up front (if necessary; you may well do fine … Read more