When I go to Subscribers > Edit (of any user), I end up on the page:
If I then click “Unsubscribe me from this blog”, the page sends me to “http://mysite.com/wp-admin/?s2mu_unsubscribe=2”, which is not correct. In my multisite, I then get redirected to the home page of the main site, without having unsubscribed anyone.
I’m using WP 3.0.5 with multisite.
What is also strange, is that when I click “Edit” for any user, the selected menu in the sidebar shows that I’m on the “Your Subscriptions” page, even though I’m editing another user’s subscriptions.
When you click on the (edit) link it will take you to the user page that looks like your own but it should have red text at the top telling you the user name of the person you are editing. If that is not there then, for some reason, your site is not accepting a $_GET request based on the ’email’ value passed in the URL of the page and that you noted in the link in your fist post. So, the URLs look correct.
Yes I did notice the red text. That’s fine. I just find it a very strange UI design choice to have that functionality under “Your Subscriptions” rather than an entire different submenu.
But regardless, the URL http://mysite.com/wp-admin/?s2mu_unsubscribe=2 is completely wrong in a multisite. I am kicked out of the admin page, and onto the front page of the root site in a multisite.
Perhaps the page title needs to change.
As for the URL being wrong – you are going to have to help me as I don’t use MU at all. What should it be? The 2 is the blog id for the blog your are unsubscribing from, right?
Since I’m on the page https://mysite.com/wp-admin/users.php?page=s2_users&email=me%40mysite.com, the URL should be the same with a different query string:
I tested the link: it works.
Instead of doing:
$unsubscribe_link = get_option('home') . "/wp-admin/?s2mu_unsubscribe=". $blog_id;
You may have to look into doing something like:
esc_url( add_query_arg( 's2mu_unsubscribe', $blog_id ) )
esc_url( add_query_arg( array('page' => 's2_users', 's2mu_unsubscribe' => $blog_id ) ) )
which would just append query string elements to the current page.
I think I’ve seen other plugins do it that way (maybe it was jetpack).
Of course, the same thing goes for the “Subscribe to all categories” link
Is your MU site using subdomains or sub-folders? Would that make any difference?
Why does the query string need to remain the same? WordPress knows which user is logged in and the blog id string is passed for the subscription or unsubscription request.
The code also handles redirects so you are sent back to a sensible place – i.e. if you Unsubscribe your membership of that blog is removed so there is no longer a profile page on that sub-blog for you to view – trying to send you to that page would result in an error.
My multisite (that’s the new name for it; I believe MU is the term for pre 3.0) setup is subdomain. I don’t know what difference that makes.
I just tried the code
$unsubscribe_link = esc_url( add_query_arg( 's2mu_unsubscribe', $blog_id ) );
$subscribe_link = esc_url( add_query_arg( 's2mu_subscribe', $blog_id ) );
and it works.
The query string doesn’t need to remain the same. In fact, I tried stripping out the page=s2_users, and the subscribe/unsubscribe functionality still works and keeps me on the s2_users page automatically. It’s just the URL that should remain the same.
I don’t understand the part about not having a having a profile. If you don’t have a profile, doesn’t going to any Admin URL automatically send you to the login page? What does that have to do with Subscribe2?
I checked out the way things are done by Automattic. Taking a look at Akismet’s configuration, I see that they use a POST form, even for just checking the “Network status”.
You know what, this reminds me that a GET form that has side effects, e.g. subscribe and unsubscribe, is a bit dangerous.
Any form that can have risky behavior should use a POST with a nonce token, to prevent CSRF, as I believe you do in other forms.
Maybe that’s the right way to fix the link anyway: just send the POST request to the current page with the s2_subscribe input tag.
What I was talking about with the ‘profile’ page is that is you are a user at administrator level, the link to this page is:
If you are a user with a capability level below this the link is different:
So, we need to be careful making changes and do lots of testing with different user account levels.
I think I understand you now.
When you click on “Subscribe” to subscribe to a new blog you are taken to that page from your current one – which is probably the right thing to do so a user can tinker with the categories selected.
When you click “Unsubscribe” you are also taken to that other blog profile when it would make more sense to stay on the current one.
If I’ve got that right in terms of my understanding I tend to agree so I’ve adopted your code suggestions – is that okay with you?
@mattyrob To be honest, I haven’t used Subscribe2 enough lately to fully understand what you’re saying. I used it years ago and I haven’t gotten around to start using it again on my new wordpress installation. So I can’t really confirm your suggestions. I can only say that the link is broken on multisite and that POST should probably replace GET. I hope that’s helpful, anyway. Sorry I can’t confirm your plans.
- The topic ‘[Plugin: Subscribe2] "Unsubscribe me from this blog" link is broken in multisite’ is closed to new replies.