![]() ![]() This filter can be used to filter the location of the registration form generated by wp_registration_url:Īdd_filter( 'register_url', 'my_register_url' ) Return add_query_arg( 'redirect_to', wpmem_current_url(), wpmem_login_url() ) If you have set a login page in the plugin’s settings, this snippet is similar to the above but will pick up your login page setting, using the plugin API function wpmem_login_url() to get the login url location and wpmem_current_url() to get the url to redirect back to: Return add_query_arg( 'redirect_to', $redirect_to, $login_page ) This code will also provide a redirect link back to the page the user was on when they clicked the login link.Īdd_filter( 'login_url', 'my_login_url' ) Set the URL according to your specific need (i.e. That could be a page that you’ve set up with the WP-Members login page shortcode, or really any other page that has login on it. Set the URL to whatever page you want users to login in on. The login redirect is similar, but using a different hook: login_url. add_filter( 'logout_url', 'my_logout_url' ) If you are running WP in a subdirectory you might have to adjust accordingly. Also, I set this example based on WordPress being located in the root of your site. (If you want the user to be redirected to a specific URL AFTER they logout, that is something for the wpmem_logout_redirect filter.)Ī couple notes about the URL you redirect to: It should be obvious that you’ll need to make this appropriate to your domain. With WP-Members, if you direct to any page in the site with the querystring ?a=logout the logout function will be executed. The logout_url hook will allow you to filter the url the user is directed to when they logout. These can be used to direct any call to wp_login_url(), wp_logout_url(), or wp_registration_url() to the locations you want to direct to. This process makes use of some little known and little used WordPress filters, login_url, logout_url, and register_url. This article will explain a simple way of redirecting these URLs to the login and registration pages set in WP-Members. Also, various plugins such as forums will utilize these urls. These can be in the comments.php template or other places in your theme. Depending on a number of factors, there may be places in your WordPress site where login and logout URLs are directing to the WordPress “backend” wp-login.php. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |