Mentioning other people in Gravity Froms and then notify them

Hi ,

I would like to know if there is a way that a user can actually mention another user in a form and then submit …

and then after submission the person that was mentioned get notified …

is this possible or does this need another add on ?

Hi Ali. Are your users going to select who they are mentioning from a list of all your users (possibly dynamically populated), or will they provide the username and you look up the correct way to contact them? Are they all registered users on your WordPress website?

Hi Chris
Thank you for responding

Yes it is the first option and it is dynamically populated , and yes they all are registered users on the website that are mentioning each other in a form that the website provides …

Ok, got it. In that case, you can use this method to dynamically populate a dropdown with users on your website:

Or you can use a plugin like this one:

That will take care of populating a field in the form from your users. I recommend having the visible Label be the username, and the not-visible Value be the user’s ID.

Now, you need to also configure a notification to be sent to the email address for that selected user.

You can take the dynamically populated user ID that was selected in the form, and get the email address of the registered user using the gform_pre_submission filter:

// apply to form 17 only
add_action( 'gform_pre_submission_17', 'get_email_from_userid' );
function get_email_from_userid( $form ) {
	// the username was selected in field 5 of the form
	$user_id = rgpost( 'input_5' );
	// retrieve the user by using the user ID
	$user = get_user_by( 'id', $user_id );
	if ( $user ) {
		// get the email address from the user object
		$email = $user->user_email;
		// store the email in field 14
		$_POST['input_14'] = $email;

That is PHP code which can be added to your theme functions.php file, or you can use a plugin such as this one to keep the code separate from the theme: Code Snippets – WordPress plugin |

Your notification can be configured to use field 14 (where you are storing the email address - this needs to be an email field, but can be hidden visibility) as the SEND TO email. The way it will work is that your visitor will select a username from the dropdown which you dynamically populated, and then your code will take the value from that field (it was field 5 in my example) and look up the email address, and store that in field 14.

This can also be done without any code using the Gravity Wiz Populate Anything Perk, but this is how you can do it with your own code if you like.

If you have any questions, please let us know.

Thank You Chris for your help , You’ve been a blessing and really helpful and i did it thoroughly .

I was wondering … Could you actually notify people inside the website in their message box like buddypress or the wordpress message box too ? like notify the user in their email and also notify them if a messaging platform of any sort between members is on …

thank you so much again and i wish you the best

Hi Ali. Yes, you could do that. To perform some other action on the site, you would not use the Notification email from Gravity Forms but would instead perform some action to create the message on the site, most likely with the gform_after_submission hook:

What it is you do after submission depends on the platform you will be using and how the notification messages work there.

@chrishajer’s answers are practically works of art with their depth of detail right!

If you know you are going to be selecting WP user(s), or all users with a specific role, the field types which Gravity Flow adds to your form may also be an option to explore. Not only does it provide you with a searchable dropdown for users, but the discussion field also lets users carry on a conversation between steps after the form has been submitted. If they select who they want to follow-up (by selecting from the User Field), that can be set as the assignee for a user input step and the assignee notification email include some/all of the discussion.

The approach I describe above might give you something close in result if not user experience to the buddypress message box. Certainly the discussion field would be a close approximation. If you are using another system to create the content and can identify the user from it, there would be a few ways to trigger a form to start a follow-up workflow:

Hope that helps,

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.