Plugin: BuddyPress Group Email Subscription

Join this plugin group to follow comments, support topics and reviews.

[Blogname] at the beginning of subject lines (12 posts)

Started 1 year ago by: Luciano Passuello

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    In WordPress, in general, all notification emails are in the format ‘[blogname] subject’, but in BuddyPress Group Email Subscription emails, the ‘[blogname]‘ part is at the end of the subject lines.

    I customized my local source files to behave like WordPress — I think it help users to identify all emails that go out of my website exactly in the same manner.

    My suggestion is to make the changes in the plugin files (If you’re interested, I have the customized versions here, I just don’t know how to send it over).

    In addition to that (or as an option) you can make the subject line fully filterable. In the current version, only the text apart from ‘[blogname]‘ (action) is filterable.

    Hope this helps!

  • Profile picture of Dwenaus Dwenaus said 1 year ago:

    probably best to have it filterable, because I prefer the way we have it – much more readable in my opinion.

  • Profile picture of Boone Gorges Boone Gorges said 1 year ago:

    I agree with Deryk (I think that the way WP and BP do it natively is not so hot), but a filter is definitely a nice idea. Deryk, would you like to do the honors? It’s probably a nice idea to pass the blogname and the subject as separate arguments to the filter so that people don’t have to build it from scratch.

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    That’s fair enough… I agree a filter is the ideal solution — and passing blogname and subject as parameters make it even better. Thanks guys!

  • Profile picture of Dwenaus Dwenaus said 1 year ago:

    this has been added to the most recent version. you can filter on
    $subject = apply_filters( 'ass_digest_subject', "$title [$blogname]", $blogname, $title, $type );
    the new version is 2.8.5

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    I am trying to make this work, but I must be missing something very obvious (as I’m a total newbie in using filters). Here it is (code in functions.php):

    function cleo_ass_digest_subject( $blogname, $title, $type ) {
    	return "[$blogname] $title";
    }
    add_filter( 'ass_digest_subject', 'cleo_ass_digest_subject', 10, 3 );

    Any help is appreciated!

  • Profile picture of Boone Gorges Boone Gorges said 1 year ago:

    Off the top of my head, it looks like this code should work. The problem might be that it’s in functions.php of your theme. Try putting it in wp-content/plugins/bp-custom.php instead.

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    Thanks @boonebgorges but unfortunately moving it to bp-custom.php didn’t help in this case. Any other ideas?

  • Profile picture of Dwenaus Dwenaus said 1 year ago:

    i think it should be more like this:

    function cleo_ass_digest_subject( $subject, $blogname, $title, $type ) {
    	return "[$blogname] $title";
    }
    add_filter( 'ass_digest_subject', 'cleo_ass_digest_subject', 10, 3 );

    the first item passed is the actual item being filtered, which in your case you are ignoring, and just making your own and returning that. and maybe the end should be 10, 4 cause you are passing back 4 vars. but i’m not positive on that.

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    Thanks for your help @dwenaus — I ran more tests, and with your help, I figured out what’s wrong:

    1. You’re right: you must pass $subject, and you must declare 4 as the number of vars.

    2. The subject filter created currently only works for digests, and not for “regular” emails.
    Hacking the code and adding apply_filters( 'ass_digest_subject'... call to other points in the code (bp-activity-subscription-functions.php, line 41, 120, 243, 1059) fixes the problem. Design-wise, I’m not sure if we should use a different filter or rename the one just created (as it’s named ‘ass_digest_subject’) and pass a new parameter telling if it’s digest or regular email…

    What do you think?

  • Profile picture of Dwenaus Dwenaus said 1 year ago:

    good that you figured it out. wp filters are tricky at first, but once you get the hang of them, they are quite powerful. i’m still learning!

    probably use another filter name for non-digest emails. offhand, something like ass_email_subject is a good name.

  • Profile picture of Luciano Passuello Luciano Passuello said 1 year ago:

    Thanks @dwenaus. Since I’m going to change this in my local copy, what’s the best way to send the changes for you to integrate in the official version?