Wordpress MailingEventSubscribe URL uses wp-admin/admin.php
I filed this two years ago in the JIRA system. It still exists in 5.11.0. Original description:
I'm setting up a mailing list in CiviCRM (originally 4.7.14, now 4.7.16) and the latest Wordpress. I created a plugin to call MailingEventSubscribe to add an email to a group, pending clicking the link in a confirmation email.
In Administer->System Settings->CMS Database Integration, I have the base page set to /civicrm. Yet when the mailing list subscribe confirmation is sent, the subscribe.url token uses http://mydomain.com/wp-admin/admin.php?page=CiviCRM&q=civicrm/mailing/confirm&reset=1&etc...
I tracked this down to /CRM/Utils/System/Wordpress.php line 280. The condition is met of is_admin() and !$frontend, so the $base is set to wp-admin/admin.php instead of using the /civicrm/ base.
I can fix this by changing line 246 of CRM/Mailing/Event/BAO/Subscribe.php to set $frontend to 1:
$url = CRM_Utils_System::url('civicrm/mailing/confirm', "reset=1&cid={$this->contact_id}&sid={$this->id}&h={$this->hash}", TRUE, '', '', 1 );
After upgrading to 4.7.21, that hack no longer worked, so I switched to a workaround of .htaccess Redirects. Since no one else has chimed in there with the same problem, perhaps there's just something strange about my configuration. But thought it worth filing a bug report again.
I have another Wordpress site where MailingEventSubscribe generates the correct URL when used within a CiviCRM extension. The problem above is when MailingEventSubscribe is called from a Wordpress plugin, which is perhaps the reason why CiviCRM thinks is_admin is 1?