how to do logout redirect to current url
wp_loginout(get_permalink()); will make hyperlink with “Log out/Log in” text and after log out it will stay in the same page, or it will direct user to log in page.
wp_loginout(get_permalink()); will make hyperlink with “Log out/Log in” text and after log out it will stay in the same page, or it will direct user to log in page.
You can use the wp_logout_url() template tag to generate a logout link. You can specify the URL that the user will be redirected to as the first pramiter: wp_logout_url( ‘http://example.com’ ); The above code will generate a URL that looks a bit like this: /wp-login.php?action=logout&_wpnonce=ba51bbcdc3&redirect_to=http://example.com/unsubscribe. You can make it into a link like so: <a … Read more
using wp-login.php as a template. is not a correct way to do that. Source You’d better use the wp_login_form() function in a custom template. EDIT: And if you want to add an option to reset password you could do this : add_action( ‘login_form_middle’, ‘add_lost_password_link’ ); function add_lost_password_link() { return ‘<a href=”https://wordpress.stackexchange.com/wp-login.php?action=lostpassword”>Lost Password?</a>’; } Source
Here’s the full working code, put it in functions.php: add_action(‘login_form’,’my_added_login_field’); function my_added_login_field(){ ?> <p> <label for=”my_extra_field”>I agree to the terms<br /> <input type=”checkbox” value=”1″ class=”input” id=”my_extra_field” name=”my_extra_field_name”/></label> </p> <?php } function check_checkbox($user, $password) { if( !isset($_POST[‘my_extra_field_name’]) ) { remove_action(‘authenticate’, ‘wp_authenticate_username_password’, 20); $user = new WP_Error( ‘denied’, __(“<strong>ERROR</strong>: Please agree to our terms.”) ); } return … Read more
if you are logged in wp_parse_auth_cookie(LOGGED_IN_COOKIE); will return array consisting wp user name, cookie hash and expiration time. This function will return null if you are not logged in. But you cannot get plain password as wordpress doesn’t store plain password.
Take a look at the source: 832 if ( $remember ) { 833 /** 834 * Filter the duration of the authentication cookie expiration period. 835 * 836 * @since 2.8.0 837 * 838 * @param int $length Duration of the expiration period in seconds. 839 * @param int $user_id User ID. 840 * @param … Read more
write this code in front page to check user is login or not: if ( is_user_logged_in() ) { … }
Alright! I understand that there is a custom wordpress login url. Also you need to login to a user’s profile. If that’s the case, I suggest a simple hack(If you legally have rights to access/modify the database). Try this: Go to cpanel and login to phpmyadmin and open the database for your website/blog. Find ‘wp_options’ … Read more
You might want to read this post about passwords protected posts. In short: Do not use them. QUESTION: Will this strategy keep the info private, or am I missing something? No, it won’t. It will even leak info to search engines and index those. What you can do is to just require the actual user … Read more
Try this. It works for me. add_filter( ‘login_redirect’, ‘redirect_non_admin_to_dashboard’), 10, 3 ); function redirect_non_admin_to_dashboard($redirect_to, $requested_redirect_to, $user ) { global $user; if( ! isset( $user->ID ) ) { return $redirect_to; } if ( ! in_array( ‘author’, (array) $user->roles ) ) { $redirect_to = site_url().’/dashboard-teacher’; }elseif( in_array( ‘subscriber’,(array) $user->roles ) ){ $redirect_to = site_url().’/dashboardwwp-student’; }else{ $redirect_to = … Read more