Redirect Using Custom Code

To write your own custom redirect code, you should familiarize yourself with the login_redirect filter. This page will explain how the filter works, and there are a few examples of how to apply this knowledge in the comments.

Here’s a very simple example to get you started:

function custom_login_redirect() {

return 'home_url()';

}

add_filter('login_redirect', 'custom_login_redirect');

This code will cause all users to be redirected to the homepage when they log in to your site. That’s all it does! If you want, you can change “home_url()” to a URL of your choosing. For example, replacing ‘home_url()’ with ‘/blog’ will direct users to your site’s blog page.

«
»
ACF (3)
Admin Column (4)
Breadcrumbs (2)
CSS (6)
Custom post types (4)
Custom Taxonomies (3)
Customizer (4)
Hooks & Filters (3)
Jquery (9)
LAMP (10)
Login (5)
Meta boxes (6)
Multisite (2)
My Code (1)
Open Graph Meta Tags (1)
Redirects (2)
SEO (4)
Theme Building (5)
Title Tags (2)
Typography (3)
Uncategorised (54)
User Roles & Capabilities (2)
White labeling (9)
Working with Images (11)
Working with videos (2)
WP Database (1)