if ( is_user_logged_in() ) { // The user is logged in. /** * You could potentially use wpmem_is_blocked() in here to build additional * logic for blocked vs unblocked content. You could also use some of the * members functions to check for membership (either if the post requires it * of if the user has it). */ } else { global $wpmem; /** * Currently, the most consistent way to check for a login error is as displayed * below checking the $wpmem->regchk value. However, as of 3.5.0, you'll be * able to check $wpmem->error using is_wp_error(): * is_wp_error( $wpmem->error ); * Depending on your current version, that may or may not be possible with * versions below 3.5.0. */ if ( 'loginfailed' == $wpmem->regchk ) { // The login failed. You can output the error message with the following: echo wpmem_get_display_message( 'loginfailed' ); /** * Note: echoing the above is an immediate output. This is suitable where * this is being used in a template or elsewhere where direct output is * suitable. If, however, this is within a filter such as the_content, * you need to return a value for content, not echo it. In such cases, * you can add this to your return variable: * * $content .= wpmem_get_display_message( 'loginfailed' ); */ // Reprint the login form. echo wpmem_login_form(); /** * Same as the above - you may want to add this to a return variable * instead if you are doing this a filter function: * $content .= wpmem_login_form(); */ } else { // Login was successful. Echo (or return) content based on login. } }
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- Using a code snippets plugin
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.