login/logout for only one page
You can use wp_login_form() to display the login form anywhere. You could hook into the the_content filter to replace the content of the page with the form when they’re not logged in.
You can use wp_login_form() to display the login form anywhere. You could hook into the the_content filter to replace the content of the page with the form when they’re not logged in.
Why don’t you make it these way: 1) Create Page Template 2) Check if user is logged in 3) if is use $wpdb global var to access database 4) do your stuff with form it may look like: /** * Template Name: User Form 1 **/ if( ! is_user_logged_in() ){ wp_redirect( home_url() ); exit; } … Read more
Here is from my previous project. The function is hooked into the template_redirect action. Inside the function there are 2 conditionals. The first is the the one that will redirect logged in user away from the login page. And the other one is to redirect non logged in user to the login page. // add … Read more
This is actually a PHP syntax error, not a WordPress error. When you issue an echo command and start a text string (using either single or double quotes), PHP will read everything that follows as part of that string until you close it with the same quote character. So in your case, you open the … Read more
If I’m not mistaken you have to set the cookie paths and domain, like it is explained here: Resolving The WordPress Multisite Redirect Loop by Tom McFarlin. In a nutshell: In your wp-config.php file, add the following lines of code: define(‘ADMIN_COOKIE_PATH’, “https://wordpress.stackexchange.com/”); define(‘COOKIE_DOMAIN’, ”); define(‘COOKIEPATH’, ”); define(‘SITECOOKIEPATH’, ”); And do so just before the line … Read more
Users created in Site_A have roles assigned to them. Same users are available in Site_B but they have no roles assigned. Create a PHP script sync-admins.php with the following code in it: <?php // load WordPress environment require( ‘wp-load.php’ ); // REPLACE ‘siteb_’ with table prefix of Site_B in line below! $tblPrefixOfSite_B = ‘siteb_’; // … Read more
These pages are accessible for users who are neither identified nor authenticated, so they are part of the frontend. They have no place in the template hierarchy, but you can style them in your theme, add custom CSS and even nav menus. By default, they look a little bit like the backend style. That’s just … Read more
If you’re hosting on Apache you could do this in your .htaccess file by adding the following before any of the WordPress rewrite rules. RewriteRule ^login$ http://example.com/ [NC,L,R] Just replace “http://example.com/” with your clients remote system URL.
Check to see if your functions.php file includes a filter for login_errors. For example, this would disable any login errors from being displayed: add_filter(‘login_errors’, function($error){ return null; }); This is sometimes done as a security measure so the reason a login attempt failed isn’t available to any would-be hacker or bot. More info on this … Read more
Try using the filter hook: function user1462_login_redirect( $redirect_to, $request, $user ) { global $user; if ( isset( $user->roles ) && is_array( $user->roles ) ) { if ( in_array( ‘administrator’, $user->roles ) ) { return $redirect_to . ‘?message=hiadmin’; } else { return home_url(); } } else { return $redirect_to; } } add_filter( ‘login_redirect’, ‘user1462_login_redirect’, 10, 3 … Read more