• Resolved malimart

    (@malimart)


    On WordPress multisite, on the first plugin activation, after the Freemius welcome screen, the user gets redirected to the wrong page:

    /wp-admin/admin.php?page=tptn_network_pop_posts_page

    The url is missing the “network” part. The correct url is:

    /wp-admin/network/admin.php?page=tptn_network_pop_posts_page

    But this can also be problematic because on Multisite, administrators do not have access to the network settings. Only Super Admins can access that page. If a regular admin activates the plugin on their subsite, they will get redirected to a page they cannot access.

    The best way to handle this is to simply redirect them to the subsite’s settings page. You can remove the exception for Multisite from your code. Here is the change we made:

    - 'slug'    => is_multisite() ? 'tptn_network_pop_posts_page' : 'tptn_dashboard',
    + 'slug' => 'tptn_dashboard',

    If you want to test this, create a wordpress multisite, sing in as a regular admin and activate the plugin on one of the subsites for the first time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    @malimart

    Sorry about this – I’ve been struggling to get this activation correct.

    Please can you tell me where you’re activating the plugin – is this on a single site only?

    And by Admin, do you mean Admin for a single site and not for the multisite?

    I think I need an extra check in there to test for network admin -> i.e. it’s a multisite admin activation.

    'slug'    => is_multisite() && is_network_admin() ? 'tptn_network_pop_posts_page' : 'tptn_dashboard',
    
    Thread Starter malimart

    (@malimart)

    Hey, no problem. In my original comment I was talking about activating the plugin on a singlesite (subsite) as a regular administrator (not network admin).

    I think you need to take into account two situations:

    1. The plugin is network activated from the network dashboard by the network admin. This activates the plugin for all sites on the wordpress multisite network. Here the network admin should probably be redirected to wp-admin/network/admin.php?page=tptn_network_pop_posts_page on the network admin dashboard.
    2. The plugin is activated on a singlesite of a wp multisite network (subsite). This can be done either by an administrator or a network admin. No matter who does the activation, they should be redirected to the plugins settings page of that particular subsite. For example subsite1.multisite.com/wp-admin/admin.php?page=tptn_dashboard.
    Plugin Author Ajay

    (@ajay)

    Thanks for the clarification. I’ve been testing this and I believe that I’ve been able to get this to work with this change: https://github.com/WebberZone/top-10/blob/master/includes/load-freemius.php#L37

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Wrong redirect on Multisite’ is closed to new replies.