There’s a filter called login_redirect
.
add_filter( 'login_redirect', 'wpse377295_login_redirect', 10, 3 );
function wpse377295_login_redirect( $url, $request, $user ) {
if ( is_wp_error( $user ) ) {
// It's possible that the $user param is a WP_Error. If so, bail out.
return $url;
}
if ( ! user_can( $user, 'update_core' ) {
// Only admin users can update core, normally.
$url = site_url( "https://wordpress.stackexchange.com/" );
}
return $url;
}
There’s a more complete example in the filter documentation’s User Contributed Notes.
References
Related Posts:
- Is there a way to send HTML formatted emails with WordPress’ wp_mail() function?
- Action hook for custom tax edit
- Hook after image is uploaded and image sizes generated
- Auto-retrieve YouTube Image for Thumbnail?
- How to call a REST endpoint when a post is published?
- __NAMESPACE__ with register_activation_hook
- Hook for URL Request
- Hook/notify when any option or setting is added or updated
- Which hooks is this? add_action(‘wp’,
- admin_notices after register_uninstall / deactivate_hook
- add_action on inherit post status
- Why does wp_enqueue_script ignore my ‘wp_head’ hook?
- action lifecycle
- Redirect users on specific post category or category page
- Returning ACF custom field from publish_post
- How to modify an add_action() inside a loop of core function
- How to get post ID in post_updated action hook?
- What is the best filter where to use register_block_type?
- How get list all users who edited post?
- Stuck in redirect loop after using wp_login action
- Hooks for Links Box [duplicate]
- Check if do_action(‘custom_action’) is hooked into?
- Hook after wp_enqueue_scripts
- wp_login Action hook with conditional tag
- Can I remove WooCommerce main content hook?
- How to alter the query using pre_get_posts hook and is_post_type_archive
- How to update WordPress core or themes and still have my child theme hooks work
- Proper indentation of code generated inside hooks
- Add parameter (time) to oembed
- Event Calendar using insert_post_data after save_post and insert_post after post_transition draft_to_schedule
- How can I count post views of REST API calls and update them in an ACF field?
- Hooking into the init action will fire it too frequently?
- Event-Driven Pattern vs MVC?
- Using hooks with extra parameters
- How to catch and modify custom field values when a page is updated
- Genesis: How to add content after aside and before the content-sidebar wrap
- new_to_publish fires multiple times
- Plugin init hook
- Best action hook for placing ical requests
- Is there a hook that fires when a row of wp_sitemeta table is updated?
- `rest_user_query` can’t access post author in post edit screen
- Post Meta Emtpy on Publish Using Transition
- How to check post type when using sanitize_title hook?
- How do I trigger a post update within a get_posts() foreach loop?
- Duplicate Cron Jobs Using wp_next_scheduled / wp_schedule_event
- Hook when editing user
- get_post_metadata causing some meta data to fail
- How to change the default mail when admin approuved an user?
- How to modify how the_content outputs a link to an internal page
- read more, even if excerpt not trimmed
- How do I prevent term from being created on create_term hook?
- How to use a 3rd party library to send emails?
- Giving the_excerpt in the place of the_content?
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- Hook to init or call explicitly within functions.php
- How to add content to the end of a page with a hook?
- WordPress’s “Text” Format
- run script on publish
- Calling add_action on a filter hook?
- Force file download in WordPress
- Remove Header and Footer if user is not logged on
- What is deprecated_argument_run meant to do exactly?
- How do I run an action after a featured image has been selected in the Gutenberg editor?
- How to run a function after wp() in the wp-blog-header.php file?
- WordPress cronjob get scheduled but function does not run
- How to add a HTML element in ADMIN edit post window?
- wp query add array by if condition
- Gravity Forms | Form Object is NULL [closed]
- Change status of page after an event (Looking for best practice advice)
- WordPress add_action the_post hook
- Add action save post when create and publish
- Hooks for Start/End of Batch Plugin Updates in wordpress
- How to load another post if condition is true
- Session management issues with WordPRess 404 Error page
- Template_redirect works, but headers aren’t sent when checking via cURL
- template_redirect hooks redirect wrong URL
- Struggling with plugin dev basics: add_action
- RTrouble passing arguments to action
- Easy Digital Downloads – How to use hooks correctly?
- delete_user hook failed
- Which things should be called with `after_setup_theme`?
- Changing header logo href for the checkout page
- Prefixing widget_posts_args Hook
- Updating a related post’s “post_modified” value
- Can’t get ID of post that relates to the comment
- Updating user meta data from external link, user not logged in
- Remove lines from RSS Feed
- Is there a hook that triggers when grant secondary user role in WordPress?
- How can I insert custom html code inside a div dynamically?
- How WordPress understands what do with the (all) key in the $wp_filter array? [duplicate]
- Why the post ID is 0 in a hook within wp_insert_post_data?
- WP-Automatic to run publish hooks
- Hide post completely and still reach it via cURL
- How do I remove an action hook by s2member
- Problem in register activation hook and Copying folder
- Why does hook priority affects admin menu permission error?
- add_action failed to display function by a plugin
- How can I modify the code generated for a PDF by the Add Media button in Classic Editor?
- How can I get the ID before after_setup_theme?
- Hook on opening a media/document