Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Subscriptions plugin - email link permissions issue
Avatar
Jonathan Blyer
Member
sp_UserOfflineSmall Offline
Jul 15, 2019 - 2:31 pm

I am experiencing an issue with the subscriptions plugin, that seems to apply to both the daily digest notification emails, as well as the individual post notification emails.

When these emails are sent out, all links are replace with the "Hidden links custom message" (found in the forum options -> Content Settings -> Post Links Filtering.

I have checked that the user's permissions are correct, and we allow users to view links in messages.

I am also unable to find within the source code exactly where this filtering is applied.

This issue is appearing on our production site, and so far I have been unable to reproduce the problem when running a copy of the site locally (I'm testing the digest emails by manually triggering the cron job under Forum -> toolbox- > cron inspector).

Any ideas on what might be going on here, or how to better troubleshoot the issue?

Since it seems to only happen in one environment, is it possible the cron job that sends out emails needs some permissions configured as well?

Thanks!

Avatar
SP Community Support
SP Moderator
sp_UserOfflineSmall Offline
Jul 15, 2019 - 3:18 pm

Hi:

hmmm...I don't have any ideas as to what might be happening there.  The local copy of the site was made from the live site with no changes? 

As far as the code, it looks like the filtering itself is in the simpleplress/sp-api\sp-ai-class-spcdisplayfilters.php file. Around line #65.  There's a function call to the hidelinks() function there.

Thanks.

Avatar
Jonathan Blyer
Member
sp_UserOfflineSmall Offline
Jul 16, 2019 - 8:47 am

I took a look at the hidelinks() function and I can see that there is a filter sph_display_hidelinks_filter.

However, if I add a filter for this, it seems like it never gets called when creating email content.

I can see that hidelinks is called from spcDisplayFilters->content($content), but I cannot see where content is called when creating an email notification.

Here is the filter I've added, maybe I am doing something wrong here?

add_filter('sph_display_hidelinks_filter', function($content, $original) {
    error_log("running sph_display_hidelinks_filter");
    return $content;
});

When Simple Press generates a notification is it getting permissions for the individual user?

Avatar
Jonathan Blyer
Member
sp_UserOfflineSmall Offline
Aug 18, 2019 - 4:42 pm

Okay I took another look at this and can see a few more details about how this is working, but I still don't have a definitive answer. It certainly seems like there is some kind of bug here, or conflict between different forum plugins.

I believe this issue is from a combination of the html emails plugin and the subscriptions plugin.

I can also confirm that this problem only occurs for the digest emails. Regular subscription emails are fine.

The function "sp_html_email_do_digests_entry" on line 353 of sp-html-email-components.php is called using the filter "sp_html_email_do_digests_entry" which gets run at the very end of composing a digest email as part of the subscription plugins "sph_subscriptions_digest_entry" filter.

On line 366 of sp-html-email-components.php the displayFilters->content() function is run on the digest email body content.

On line 64 and 65 of 'sp-ali-class-spcdisplayfilters.php' this content() function will attempt to hide any links included in the content if this particular forum does not have permission to view the links.

# 14: hide links
$forum_id = (!empty(SP()->rewrites->pageData['forumid'])) ? SP()->rewrites->pageData['forumid'] : '';
if (!SP()->auths->get('view_links', $forum_id)) $content = $this->hidelinks($content);

It is difficult to tell exactly what this code is doing, but it would seem the problem is somewhere in these two lines.

I'm not entirely sure what sp()->rewrites is, but is it possible that we are trying to get the forumid from part of the current navigation through the site, or the current page?

I suspect this won't work since this function is called as part of a cron job through the subscription digest plugin. I suspect the forumid is returning blank, and the call to sp()->auths then always returns false, thereby always calling the hidelinks function.

This might also help explain why I'm seeing different behavior in different environments (depending on how "sp()->rewrites->pageData" is working...).

Any insight is much appreciated!

Avatar
Jonathan Blyer
Member
sp_UserOfflineSmall Offline
Apr 8, 2020 - 12:41 pm
I was able to work around this with the filter below. This will completely disable the 'hide links' functionality.... so it is not perfect, but works for our purposes.

add_filter( 'sph_display_hidelinks_filter','filter_forum_links', 10, 2 );
function filter_forum_links($content, $original) {
    return $original;
}
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616