The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
How can I include c...
 
Share:
Notifications
Clear all

Question [Solved] How can I include custom field to actual message

11 Posts
3 Users
3 Likes
870 Views
Posts: 6
Topic starter
(@validhan)
Active Member
Joined: 2 years ago

How can I include custom field to actual notification or email message?

For example if I choose department and post comment it is displayed on comment. 

But on the notification message there's no custom field, only comment content.

So how can I include custom fields on comment content?

Thank you

Screenshot 13

 

10 Replies
Asti
Posts: 7119
 Asti
Support
(@asti)
Illustrious Member
Joined: 6 years ago

@validhan,

How can I include custom field to actual notification or email message?

Please clarify a bit what kind of email you mean. 

8 Replies
(@validhan)
Joined: 2 years ago

Active Member
Posts: 6

Hello @asti,

I mean about actual notification sent to particular user. I'm using WpDiscuz for custom fields.

For example UserA posts comment "@UserB test" and choses IT department (custom dropdown field).

A mail notification has been sent to UserB's email address. As a result, the actual content of the notification displays as "test" without including the custom field "IT Department".

Is there any way to show custom dropdown fields in that message that was sent to UserB?

Maybe I can do it with Meta keys?

Screenshot 13
Screenshot 12

 

Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 7119

Thank you for the clarification @validhan,

I'm going to ask the developers if there is a solution we can provide you. I'll update this topic once I get some news for you. 

(@validhan)
Joined: 2 years ago

Active Member
Posts: 6

Hi @asti Maybe you can help me with alternative solution.

How can I copy value from dropdown once I select it to comment area as text?

Maybe you can show me code on how to copy dropdown value to comment area once I select it? For example if I select IT department I want it to appear in comment text area like: Comment section( "IT Department:"...comment ...)

Screenshot 14

 

Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 7119

@validhan,

The previous option is easier. We'll provide you a solution with the next version of the wpDiscuz plugin. Please wait for the next update. I'll update this topic with the new hook-code. So the mail will include the value of the custom field. 

(@validhan)
Joined: 2 years ago

Active Member
Posts: 6

Hi @asti There's an update

Comments – wpDiscuz v7.5 – 12.10.2022

But I custom fields still does not appear in Email

Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 7119

@validhan,

Please follow the steps below: 

1. Put the following hook code in the functions.php file of the active theme:

add_filter('comment_notification_text', function($notify_message, $comment_ID){
	$customFiled = get_comment_meta($comment_ID, 'key',  true);
	if($customFiled){
		$notify_message .= "\n" ;
		$notify_message .= "Department : " . $customFiled;
	}
	return $notify_message;
}, 9, 2);

This instruction should be helpful for you: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

2. Replace the red-marked "key" value with the custom field's meta key. This video shows how to get the meta key of the custom field: 

3. The red-marked "Department" phrase also can be changed as you like. 

(@validhan)
Joined: 2 years ago

Active Member
Posts: 6

Hi @asti  Thanks for all information and hook code. I test it on my wordpress but unfortunately it does not worked. I even tried to implement it on new installed wordpress with only WPDiscuz plugin but still it does not work as well.

Please can you check and test the code again if it is correct.

Note please I tried to implement it directly from functions.php and plugin that you suggested as well. I even tried to specify my own meta key value for custom field and put it into key  field. 

Please can you provide some solution.

Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 7119

@validhan,

We've checked it several times, it works fine. Please see the screenshot: 

image
Posts: 2
(@zohan)
New Member
Joined: 1 year ago

I'm also in similar situation and wondering perfect answer about it. I get lot of ans through peoples and internet but all are useless. But thanks to all you guys for giving best answer according this issue.

Share: