Skip Navigation

[Resolved] Automatically assign TWO parent post types to ONE child post type via cred form

This support ticket is created 7 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 14 replies, has 2 voices.

Last updated by Rita 7 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#444271

Hi there
Hoping someone can help... I know this is possible but I can't get it to work.
I have 2 PARENT post types (biography + travelbug-listing') and one CHILD post type (message).
I have a PAGE with the cred form to create a new message called 'new-message'.
I have a VIEW of the biography post type - with a filter allowing only biographies that are the same author as the 'page where this view is...'.
This view is sitting in the 'travelbug-listing' content template.
In this view is a child cred form link to create a new 'message, like this:
[cred_child_link_form form='26441' parent_id='-1' text='New Message' target='_blank']

I have done this because I want the cred form to send an email notiification to the author of the travelbug-listing - which is the same author as the biography. In the cred form I therefore have:

This effectively

#444281
Screen Shot 2016-10-07 at 19.54.40.png

...sorry technical mishap this end. We can't edit posts anymore? To finish my post:

Currently, re the CRED FORM, I have this set up: https://toolset.com/forums/topic/send-cred-email-notification-to-parent-post-author/

I basically need the author of the message and the author of the two parent posts; biography and travelbug-listing, to see ,displayed in the 'message' post type - what biography and what travelbug-listing the message belongs to.

Hope this makes sense! Little diagram attached to help...

Thanks in advance!
R

#444288

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rita,

Thank you for contacting our support forum.

In short you want to send an email to the Authors of the Parent CPT correct?

Please let me know.

Thanks,
Shane

#444323

yes, sorry I tried to explain the setup in case it matters..
in short I want to be able to send the email notification from the cred form to the author of the BIOGRAPHY saying:
'the author of the MESSAGE has posted something on your TRAVELBUG LISTING (the author of the biography is also the author of the travelbug listing)'
hope that makes sense?!
🙂

#444326

Lets say 'Jack' created 5 posts - one is a biography and 4 are travelbug listings.
Then 'Eva' comes along, see one of the travelbug listings and posts a message.

When she posts a message from the travelbug listing page I want the cred form to send an email notification to Jack saying 'Eva has posted a message about your travelbug listing!' and specify which travelbug listing.

🙂

#444328

The problem is: the child cred link only allows me to specify one parent post.
I need the child cred link to specify 2 parents to the 'message' post so that:

1. the message post knows which parent travelbug listing
2. the message knows which parent biography so it can pull the custom field email address from the biography post to send the email

#444332

(ok.. I see that my last message might be my shortest and best explanation. apologies for the repeats! just tired..)

#444343

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rita,

But does your current setup with this code here work as it should ?
https://toolset.com/forums/topic/send-cred-email-notification-to-parent-post-author/#post-442793

Sorry for the many questions but I like to understand fully the scope and also how far you are in implementing this. It will help to eliminate any form of confusion between us.

Thanks,
Shane

#444345

Yes. What I have works perfectly right now because the 'message' post is passed the '$biography' as parent post id via the child cred form - I have child cred form link sitting in a view of the biography - which is sitting on the travelbug listing. If I can find a way to get that child cred form to also assign the travelbug listing as another parent - its sorted! Maybe I have to change the set up.. Am open to suggestions!

#444841

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rita,

What you can do is to use a hook to assign that ID to the next parent. However i'm trying to figure how we can make this Dynamic.

The hook works by populating the hidden custom field on the child post so that its linked to the parent.

Would there be a fixed amount of Biography?

Please let me know.

Thanks,
Shane

#444894

Hi Shane
Ok sounds good. You will have to walk me through as I don't know much about 'hooks'.
So yes. Every user/author 'owns' 1 biography post type but can create many travelbug listings and messages.

#445375

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rita,

Ok so since each user owns 1 biography, is it that User who is going to create the message ? or any user can create the message.

The reason why I asked is that We can use that current user ID to get the biography that the user created and assign that biography as the parent of the message.

Please let me know.

Thanks,
Shane

#445386

Hi Shane

No I am sorry I may have explained incorrectly then...
Every user can create one 'biography'.
Every user can create many 'listings' and many 'messages'.
Scenario:

User 1 has created one biography and one listing.
User 2 has created one biography.
One day User 2 reads User 1's listing post and clicks a button displayed on the post to create a new message post.

What the user doesn't know is that on the listing template is a VIEW of biographies, limited to 1, that are the same author as the listing post - in this case, that is User 1's biography post.

The child cred link to create a new message post is embedded in this view. Therefore, when a new message is created it is automatically linked as a child to the biography and NOT the listing.

I did this because I need to pull the email address custom field from the biography post so that the new message cred form can send the email notification to the author of the listing post.

What I CAN'T do is ALSO link the listing post as a second parent to the new message post.

Well. I CAN make the user do it manually by adding a parent select field in the new message post. The user then has to search a thousand listing titles to try to find the listing he was just looking at... For user experience, this isn't an option...

Perhaps I need to rethink the structure....?

I have moved the elements all around but cannot find a solution within the limits of my knowledge. If I make the message post a child of the listing I cannot get the email custom field from the biography post. Etc...

Hope this helps explain! Perhaps it cannot be done.

#445890

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rita,

Thanks for the detailed explanation.

Personally the easiest approach is to allow the user to select the listing, reason being is that we have no solid way of predicting which listing a message should be attached. That is the biggest issue we have 🙁

So it wouldn't be possible to code this unless we know how to code the prediction.

Thanks,
Shane

#445894

True... 🙁
I will rethink the whole structure...
Thanks anyway 🙂

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.