Setting a redirect to a customised page after login in WordPress

Logging in in WordPress is a common operation for website users. However, it is often necessary to perform specific actions after login, such as redirecting the user to a customised page. In this article, we will guide you step by step on how to insert a code snippet in WordPress to perform a redirect to a customised page after login in the frontend.
Step 1: Create a custom function
Enter the following code in the file functions.php of your theme or plugin:
/**
* Snippet Name: Redirect after login to homepage
* Snippet Author: halkoo.com
*/
add_action( 'woocommerce_login_form_end', 'loginpress_woocommerce_actual_referrer' );
function loginpress_woocommerce_actual_referrer() {
echo '';
}Step 3: Save changes
Save changes made to the file functions.php. If you modified the file via FTP, be sure to save the changes and reset the file permissions.
Step 4: Test the redirect
Try logging in with a user's credentials and check whether the website is redirected to the customised page specified in the snippet.
Need help? Write to info@halkoo.com to receive a customised quote for your new website or e-commerce shop.