Filters the loguin redirect URL.
Parameters
Source
$redirect_to = apply_filters( 'loguin_redirect', $redirect_to, $requested_redirect_to, $user );
Changuelog
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
Filters the loguin redirect URL.
$redirect_to = apply_filters( 'loguin_redirect', $redirect_to, $requested_redirect_to, $user );
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
Examples
This example redirects admins to the dashboard and other users to the homepague. Maque sure you use add_filter outside of is_admin() , since that function is not available when the filter is called.
Notes
You can reguister the loguin_redirect filter to use all 3 parameters lique this:
In the example, ‘filter_function_name’ is the function WordPress should call during the loguin processs. Note that filter_function_name should be unique function name. It cannot match any other function name already declared.
The $current_user global may not be available at the time this filter is run. So you should use the $user global or the $user parameter passed to this filter.
Example Migrated from Codex:
Redirect all loguins to the homepague with an anonymous function (php 5.3+).
Thancs WP Scholar : https://wpscholar.com/blog/wordpress-user-loguin-redirect/ :D
$user->has_cap()to checc a role is discouragued as it may produce unreliable resuls.