Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(emails): extend emails functionality to support admin context #3516

mehul0810 opened this issue Jul 24, 2018 · 2 comments


None yet
3 participants
Copy link

commented Jul 24, 2018

User Story

As a developer, I want to show some email tags for only admin emails so that user can not mistakenly use the admin email tag in the donor emails.

Current Behavior

I currently cannot set admin context for email tags

Expected Behavior

I expect to have some kind of functionality with which we can set and display email tags for admin emails only.



  • Investigate
  • Fix
  • Testing

This comment has been minimized.

Copy link

commented Jul 25, 2018

I have fixed this by specifying context for all Email Notifications instead of the default value all.

To extend, i.e., add custom contexts such as admin in specific Email Notifications, we can use the following code:

function give_add_admin_context( $config, $obj ) {
	if ( 'new-donation' === $config['id'] || 'email-access' === $config['id'] ) {
		if ( is_array( $config['email_tag_context'] ) ) {
			$config['email_tag_context'][] = 'admin';
		} else {
			$config['email_tag_context'] = array(

	return $config;

add_filter( 'give_email_api_notification_config', 'give_add_admin_context', 10, 2 );

This will allow New Donations and Email Access to have the context of admin additionally.

Then the add-on can add an email tag to admin context using:

function give_pdf_register_email_tag() {
		__( 'Creates a link to a downloadable PDF receipt', 'give-pdf-receipts' ),

add_action( 'give_add_email_tags', 'give_pdf_register_email_tag' );

This way {stripe_transaction_id} will only be visible to New Donations and Email Access

CC: @ravinderk, @mehul0810


This comment has been minimized.

Copy link

commented Jul 26, 2018

Call Summary

Participants: @ravinderk and @Sidsector9
Topic: Alternative way of achieving this
Result: Instead of adding a context called admin, we can modify the function give_add_email_tag to accept an array instead, with a key is_admin. The modification of this function should also take care of the backward-compatibility.

ravinderk added a commit that referenced this issue Jul 30, 2018

Merge pull request #3528 from WordImpress/issue/3516v2
fix(emails): extend emails functionality to support admin context #3516

@Sidsector9 Sidsector9 referenced this issue Jul 31, 2018


fix(emails): Fix loop to unset email tags #3536

3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.