如何在此 Wordpress 重定向插件中的 "siteurl" 末尾添加 slug?

How can I add a slug to the end of "siteurl" in this Wordpress redirect plugin?

在 Wordpress 多站点上,我使用“redirect-multisite-user-to-their-own-site”插件让从前端登录的用户重定向到他们自己的特定博客。但是,此插件仅重定向到用户博客的主页(例如 mulstisite.com/users-site),而不是仪表板(例如 mulstisite.com/users-site/wp-admin)。我希望用户被重定向到他们的仪表板。

在插件的代码中(见下文,完整包含),它们有 wp_redirect($user_target_site->siteurl);。我还不太了解 PHP,需要它以某种方式转到 $user_target_site->siteurl + /wp-admin。我怎样才能做到这一点?我很高兴编辑插件并创建我自己的插件,以防止它被插件更新覆盖。

    <?php
    /*
    Plugin Name: Redirect multisite user to their own site
    Plugin URI: https://wordpress.org/plugins/redirect-multisite-user-to-their-own-site/
    Description: If the current user in a multisite environment accesses a subsite to which access has not been granted, then redirect the user back to their own site. This plugin requires PHP 5.3 or newer because it uses PHP namespaces.
    Author: Mark Howells-Mead
    Version: 1.1.1
    Author URI: https://www.permanenttourist.ch/
    Text Domain: redirect-multisite-user-to-their-own-site
    */

    namespace MHM\MultisiteRedirectuser;

    class Plugin
    {
public function __construct()
{
    load_plugin_textdomain('redirect-multisite-user-to-their-own-site');
    if (is_multisite()) {
        add_action('parse_request', array($this, 'checkAccess'));
    }
}

public function checkAccess()
{
    global $current_user, $wpdb;
    $current_site_id = (int) $wpdb->blogid;
    $user_sites = get_blogs_of_user($current_user->ID);
    if (is_array($user_sites)) {
        switch (count($user_sites)) {
            case 0:
                if (is_user_logged_in()) {
                    do_action('redirect-multisite-user-to-their-own-site/no-sites', $current_user, $current_site_id);
                }
                break;
            case 1:
                $user_target_site = array_values($user_sites)[0];
                if ((int) $user_target_site->userblog_id !== $current_site_id) {
                    do_action('redirect-multisite-user-to-their-own-site/redirecting', $current_user, $current_site_id, $user_target_site->siteurl);
                    wp_redirect($user_target_site->siteurl);
                    exit;
                }
                break;
            default:
                if (!array_key_exists($current_site_id, $user_sites)) {
                    do_action('redirect-multisite-user-to-their-own-site/not-allowed', $current_user, $current_site_id, $user_sites);
                }
                break;
        }
    }
}
    }

    new Plugin();

只要您了解更改插件代码的含义,请尝试更改此行;

wp_redirect($user_target_site->siteurl);

为此:

wp_redirect($user_target_site->siteurl . "/wp-admin/");