Here’s the solution if anyone’s interested:
add_filter('login_redirect', function( $url, $query, $user ) {
$user_info = get_userdata($user->ID);
return get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/?login=1';
}, 10, 3);
add_action('current_screen', function ( $user ) {
$userID = get_current_user_id();
$user_info = get_userdata($userID);
if ($_GET['login'] == 1 && $user_info->primary_blog) {
$primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/edit.php?post_type=visitor';
$site_id = $user_info->primary_blog;
if (!current_user_can_for_blog($site_id, 'create_users')) {
wp_redirect( $primary_url );
exit();
}
}
});
Related Posts:
- Integrating WordPress to my website, while keeping my own authentication system
- Remove/unset options field from backend Settings->General?
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Create form which redirects to site in network?
- Remove node from multisites?
- Custom PHP-coding in MU installs
- Get author full name
- Add a wp editor to custom plugin and save data
- How to use wp_insert_user on WordPress Multisite?
- Removing jQuery migrate and working with dependencies
- How to Use the Function is_user_logged_in To Display Different Menus?
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Add value to usermeta without removing previous values?
- Edit postmeta when user changes user role?
- How to add default images into theme customizer image control?
- String replace WordPress Site Title
- WordPress Ajax Data problem
- Remove all nav menu classes ( but keep useful ones… )
- Add attribute / custom attribute to product in woocommerce
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- PHP can I add line numbers to file_get_contents()
- Displaying theme options in css
- Hide wordpress field if data is empty in post!
- Remove one value in dismissed_wp_pointers?
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- Accessing data from a non-WP database/table within a page content
- Changing layout with wp_customise
- Selectbox in admin panel function linking to CSS
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Add New User, extra fields which are required?
- WordPress returns “The link you followed has expired” error page whenever I add a new site, add a user etc
- Customizer: active_callback and sanitize_callback incompatibility?
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- custom url rewrite for wordpress
- Menu jumping when calling it via PHP
- Output Video Download Link in template
- Modify custom field input data before creating a new post
- “operation successful” message
- Change order of custom submenu link in WP Admin?
- Count posts on multisite with blog id
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Create page template via functions.php?
- How to create a field in customize and show that in header.php?
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- Delete or edit postmeta with specific meta_key?
- Known Issues in WordPress When Upgrading PHP to ver 7
- WordPress homepage setup not working on first load
- Update if post with specific title exists
- Why, when moving a WordPress multisite network, have my theme customisations stopped working?
- pass html code to worpdress
- How do I custom code the start page?
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- Kohana Frontend, WordPress Backend
- How can I fix this code [duplicate]
- is_user_logged_in returning nothing on custom page
- Customize field names in backend profile edit page through function.php [duplicate]
- how to add datas in taxonomy to post with wp_insert_post
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- Change permalink structure specific category
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Create Columns with Custom Walker and CSS Classes
- I need to display posts in subcategory beside posts in main category
- How can I check that the acf field value is not a duplicate when adding a post?
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- How can I update WordPress plugins or WordPress itself in all server?
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- Inserting a class on before_widget if checkbox is checked
- Add a new view on the Woocommerce account page
- How do I add a predefined class to a custom html element?
- Internal Server Errors – Moving working multi-site install to my localhost
- How to identify which php file a plugin is using on page load?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
- Add custom attribute to product’s HTML to woocommerce cart page
- Automatically refresh page if widget is added to page?
- custom field – changing an element or background of id div – different versions not working
- Add .php to end of all WordPress Pages (multisite)
- List all blogs apart from the current blog and main blog in WordPress Multisite
- Adding users to another blog
- How to get php file based on URL in WordPress
- Replace Underscore (_) on Space ( )
- Why isn’t my custom Javascript showing up in my custom template?
- use system script advertising in wordpress multisite
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- How can I show only if custom field has content [closed]
- media-uploader insert into post is not inserting
- How to hide something from custom home page with php code?
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- WPMU schedule doesn’t execute actions
- Where can I find the code for the menu page meta boxes?
- .htaccess on multisite and roots theme?
- wp_head makes my custom page template not work in Customizer?
- Woocommerce linking variations
- How to continuously developing a WP site that is already deployed in production without damaging it during development
- hello can you advise how to fix the error?
- Add multiple HTML attributes to an Elementor button
- Internal server error when enabling Multisite in WordPress