Support » Plugin: Notification - Custom Notifications and Alerts for WordPress » Discord Merge Tags Disappearing

  • Resolved DuelingOgres

    (@duelingogres)


    Hey Kuba!

    I just installed the Notifications plugin and quickly purchased the Discord add-on only to discover that every time I try to add a merge tag or a Discord-safe role notification (like this <@&443118576942055456>) and SAVE the notification, it removes them from the text boxes but leaves the rest of the characters and does not function as intended.

    Thoughts?

    • This topic was modified 5 months, 3 weeks ago by DuelingOgres.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    Hey, the reason for that is the <@&443118576942055456> which is treated as an HTML tag and stripped. In which Discord field are you trying to use this?

    It seems to be happening in any field I put it in.

    I thought it was also stripping the merge tags, but that is functioning now. It may have just been a really late night last night when I was first attempting to set it up ^.^

    Is there a way to pass the role ID from Discord through without treating the <@&443118576942055456> as an HTML tag?

    I think that will actually alert the role it’s intended for.

    • This reply was modified 5 months, 3 weeks ago by DuelingOgres.
    • This reply was modified 5 months, 3 weeks ago by DuelingOgres.
    Plugin Author Kuba Mikita

    (@kubitomakita)

    Hmm, this is a broader issue related not really to Discord extension, but to the core plugin. I’m going to check out how we can adjust the sanitizers to allow for HTML tags in inputs.

    Would you be comfortable to install the development version of the plugin, before the official release?

    I’m not sure if I would feel comfortable, since I’m a novice using plugins and tend to poke the code with a pointy stick until it works. For instance, right now I’m trying a custom global merge tag to input the <@&443118576942055456> to see if it will populate correctly on the Discord side:

    notification_add_global_merge_tag( new BracketSpace\Notification\Defaults\MergeTag\StringTag( [
    	'slug'     => 'com_leads',
    	'name'     => __( 'Discord Role ComLeads', '<@&443118576942055456>' ),
    	'resolver' => function( $trigger ) {
    		return get_option( 'com_leads', '<@&443118576942055456>' );
    	},
    ] ) );

    I’m not sure what should go in the ‘textdomain’ field, so I just placed the role ID.

    In any case, I do follow instruction fairly well, so if I need to be a test subject, I can comply.

    UPDATE
    My custom global did not work, it still stripped the “HTML” lol

    • This reply was modified 5 months, 3 weeks ago by DuelingOgres.
    Plugin Author Kuba Mikita

    (@kubitomakita)

    I’m proposing the development version only to get it working for you as fast as possible. The feature will be tested and that’s only a matter of uploading the plugin once again. I’d deliver just a zip file 🙂

    The textdomain is used for translations. You can leave it as it is, as it was, remove it or change to duelingogres 🙂 Doesn’t really matter if you don’t intend to translate this.

    You, sir, are thinking good with the merge tag! The reason why it strips the HTML as well is that you used StringTag. You could try to change the new BracketSpace\Notification\Defaults\MergeTag\StringTag part to new BracketSpace\Notification\Defaults\MergeTag\HtmlTag – that should help

    Nice! That did the trick! Thanks a lot, @kubitomakita !!

    So for anyone who comes across this, here’s my updated code, placed in the functions section of my child theme:

    notification_add_global_merge_tag( new BracketSpace\Notification\Defaults\MergeTag\HtmlTag( [
    	'slug'     => 'com_leads',
    	'name'     => __( 'Discord Role ComLeads', 'lurxquad' ),
    	'description' => __( 'Alerts the Discord Role @CommunityLeader', 'notification' ),
    	'resolver' => function( $trigger ) {
    		return get_option( 'com_leads', '<@&443118576942055456>' );
    	},
    ] ) );

    Remember that you’ll need to create a webhook in Discord for the notification (more info on how to do that here bracketspace.com/downloads/notification-discord/) and you’ll need the Global Merge Tags template from here docs.bracketspace.com/notification/developer/triggers/adding-merge-tags-to-existing-triggers

    You’ll also need to get the ID of the role or user you’re trying to tag, which can be done in Discord by a) right-clicking the role or user and looking for “Copy ID” and then wrapping it with <@&[ID NUMBER]> or b) typing in \@[ROLE] to output the ID in the aforementioned format.

    • This reply was modified 5 months, 3 weeks ago by DuelingOgres.
    Plugin Author Kuba Mikita

    (@kubitomakita)

    Woohoo!

    Thanks for the solution.

    I’m going to resolve the field sanitizing issue as well, that will be helpful for other things.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.