Skip Navigation

[Resolved] Email to parent parent post author without sharing email via url param

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to send the form notification to a parent post instead of the current post of the form.

Solution:
This can be done, either by:
- Adding a generic email field and passing the value from the parent post using the item attribute.
- Adding a generic field and passing the parent post id using the item attribute.
- Using custom code for altering the recipients of the notification.

Read all the suggestions in the replies below.

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by himanshuS 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1897943

I have two post types: review request and request.

Professionals request reviews and experts review their work. I want the reviews to be blind so I don't want experts to know the professionals email address. Therefore, I do not want to pass professional's email as url param and capure it in the post form for reviews. (This is the way I was able to send email to parent post author earlier).

I was wondering if I could pass the user id in url param and then use the user id to send a notification to the wordpress user. However, I am not sure how to setup a generic user id field. I don't see any option on the post form to do that.

How can I email the professional that their work has been reviewed by an expert without sharing professional's details with the expert.

#1897947
generic and custom number fields created.png
user-id field not available.png

Screeshots explain further.

#1898723

Hello and thank you for contacting the Toolset support.

I might need more details to better assist you with this request. Are you creating a relationship between these two custom post types? What type of relationship? One-to-one, one-to-many?
What forms are used in there?

In the meantime, it is worth to mention the cred_notification_recipients hook that allows changing the recipients of a form notification.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

You may need to use Toolset relationships functions to get the email from a related post. https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

#1898767

Hey Jamal,
Good questions. The two posts are in a one-to-one relationship. The form that should trigger notification is the submit endorsement form (this will publish the endorsement post). The form is on a page and the page is shared with the endorser when a professional requests an enorsement ( when a professional publishes an endorsement request). On the endorsement form, the endorsement and endorsement request are already linked by populating endorsement request id through url param. So, the two posts will be linked when the endorser submits the form.

I hope this helps.

#1898817

Thank you for your feedback. But, I am afraid I still do not see the whole picture.

Would it be possible to allow me temporary access to your website to check this closely? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Please let me know what forms are involved and where(url) it is being used.

If it's not possible, please prepare a minimal example on this test site and I'll check it and see what we can do.
hidden link

#1899287

Thank you for your feedback and for the site's credentials. I checked all the provided forms and Elementor templates, and I must confess, I still do not know where do the experts see the "Endorsment Requests" and the Form or button-to-form in order to submit and "Endorsment".

But, I can see that you are using the item attributes in some of the forms notifications to get the parent "Endormsment Request" data. For example here hidden link
So, I will suggest using the same in order to get the ID of the author of the "Endorsement Request". Put the ID in a generic field. Then wrap the generic field inside a hidden <div>:

<div style="display: none;">
  ==> Generig field for the author ID here.
</div>

You can then get the author ID with the following shortcode:

[wpv-post-author format="meta" meta="ID" item="@endorsement-request-to-endorsement.parent"]

Then, you can use this generic field in the notification. Here hidden link

I hope this helps. If you still encounter any issues please describe the flow that you have implemented in steps:
- User(login/password) goes to the page(URL) to submit an endorsement request.
- Expert(login/password) can see the requests here(URL).
- Expert should click here(screenshot) to see the form.

#1899581
hidden field.png

The emdorsment form link is emailed to the endorser from the "submit endorsement request button". If you go to notification for "submit endorsement request button", you will see I am populating post elements as url params. (link - hidden link)

I want to avoid sharing user id as url param so I would like to use the shortcode solution you suggested. But, I have a questions.

Will the shortcode work before the endorsement has been published? The code will trigger on submit endorsement form so if the endorsement is not published, there would be no link between endorsement and endorsement request and hence the shortcode will return no value. Thoughts?

You can also look at the screenshot for a hidden field. It allows to use the field for user id but how do I pass value in that field if the shortcode does not work. Even if that does not work, there is no way to pass url param in the hidden field (this won't be ideal as user's id will be exposed on the url).

#1900079

The shortcode is not correct inside of the condition expression. hidden link

But, I don't understand why using this conditional group at all. Can you elaborate more?

You can also look at the screenshot for a hidden field. It allows to use the field for user id but how do I pass value in that field if the shortcode does not work.
Using a shortcode and the item attribute. In the expert mode editor, the value of the field should use the following shortcode:

[wpv-post-author format="meta" meta="ID" item="@endorsement-request-to-endorsement.parent"]

I am sure you will understand that I work on many customers websites per day and I may lose track of how each website is working, that's why I'd really like that you describe in steps how the flow is. That way, I'll understand better and I can easily run tests. An Ideal explanation would be as follow:
1. Visit URL(xxx) as guest and enter the following values(example) in the form.
2. Login as expert user(username/password) and go to URL(xxx).
3. Enter the following values(example) and submit.
4. etc.
Because as of now, I still don't know exactly what form will lead me to what other form and where I can see and test.

#1900387
user email.png

The shortcode does not work as the post has been created yet. I think it cannot find a parent when the child is not available.

This is how you can try it:
1) Login in with admin account I shared with you
2) Go to hidden link
3) Here you will see all the expert review requests
4) Select a request and click on it. It will take you to the expert review request post page
5) Click on the review project button
6) This takes you to the form to submit expert review
7) As per the logic for shortcode to get author for endorsement request, I have added the shortcode to a field in the form. Shortcode: [wpv-post-author item="@expert-review-request-to-expert-review.parent" format="meta" meta="user_email"]
8) You can also check the shortcode on the following form: hidden link
9) You will notice that the shortcode does not populate the field -- expert review requester email.
10) I can pass author email info in the url as a parameter but I don't want to share user information with reviewer.

My question: how do send an email notification to the author of a review request (without using url parameter) when the reviewer submits the expert review form.

#1902263

Sorry, but I stuck on the 2nd step. I went to hidden link but there were no requests. hidden link
I tried to create a new request with a test card but I was stuck at this step hidden link
Without being able to test the process, I am afraid, I remain with little help.

Regarding the screenshot of the email field, that could be a good solution. If you want to hide the email from the Expert, you can hide that field with custom CSS. Example: hidden link
But, if the expert is familiar with Web development, he can find the email by inspecting the page HTML.
You may want to pass the user ID instead of the email:

	<div class="form-group" style="display: none;">
		<label>[cred_i18n name='expert-review-requester-email-label']Expert Review Requester Email[/cred_i18n]</label>
		[cred_field field='expert-review-requester-email' force_type='field' class='form-control' output='bootstrap' value='[wpv-post-author item="@expert-review-request-to-expert-review.parent" format="meta" meta="ID"]']
	</div>

Then configure the notification as suggested in this screenshot hidden link
But the field needs to be a generic field.

There is also the possibility of using custom code as suggested in this previous ticket https://toolset.com/forums/topic/cred-notification-to-email-from-parent-post-field-no-longer-working-after-types-3-0-update/

#1904693

My issue is resolved now. Thank you!