Skip Navigation

[Resolved] I need to implement a cred child notification

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

Problem: I would like to access the name of the page where my CRED form is included, in the post created by the CRED form. The page where the form is shown has no parent/child relationship to the post created by CRED.

Solution: Use a generic field in your CRED form to capture the current page ID. Use the page ID to get the page title, then update your post's meta information to include the page title.

[cred_generic_field field='currentpageid' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-id]"
}
[/cred_generic_field]
add_action('cred_save_data', 'save_parent_title',10,2);
function save_parent_title($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==550)
    {
        if (isset($_POST['currentpageid']))
        {
            $parent_title = get_the_title($_POST['currentpageid']);
            update_post_meta($post_id, 'wpcf-field-name', $parent_title, true);
        }
    }
}

Relevant Documentation: https://toolset.com/documentation/user-guides/cred-api/#csd
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_generic_field

This support ticket is created 7 years, 2 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 23 replies, has 3 voices.

Last updated by oriolc 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#488680

I have similar problem as described in this topic:
https://toolset.com/forums/topic/cred-notification-2/
My problem change because i have a lot of parent post, not just only one.
I need to create a cred form to send a notification to the parent post author with the parent post title.
I' ve tried a lot of things (create a child post as in the topic, create custom post fields for parent post,use contact form 7 with dinamical ) but I can't not obtain the parent post title or the parent post email.
My example page is: hidden link. You can find the cred form in the sidebar.

Thank you very much!!!!!

#488734

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

Thank you for contacting our support forum.

First I must establish some context to see what has already been done 🙂

Does each Child have 1 parent ?

This is a One to Many relationship meaning that child posts can only have 1 parent correct? but the parent can have many children?

If this is so then we would need 2 views, one to display the parent Title and one for the Parent Author email. Also is the author email stored on the Parent post ?

Please let me know.
Thanks,
Shane

#488883

Hi!!!!
I have diferent parents for one child....
I created different custom posts for different posts (parents).
After that i need to insert a cred form to send a direct notification to the post author and to me.
To do that, i followed the example that i mention in the last post.
I created a custom post (child) and custom fields. With that parameters I'd created a cred form and I inserted in the diferent posts, but I won't recieve the parent post title.
The problem to follow the post example is the need to insert a form value, but I can't do it for my different posts.
Is there a way to do it for all them?????
Sorry for my english, but if you go to the example page that I created you'll understand easy.

#489132

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

When you say you have different parent for one child, does that Mean you have a Many Many relationship which would include an intermediary post type?

Would you mind allowing me to have admin access to check further on this for you ?

The private field will be enabled for your next response.

Looking forward to hearing from you soon.

Thanks,
Shane

#492099

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

So on this page here hidden link

You want to send the notification to the Author of that page whenever someone contacts them through the Form correct?

Just confirming before I can make a suggestion.

Thanks,
Shane

#492312

Yes, I need to send a message to the author post and in this message I have to insert post title too. The cred form I'd created is in part with title: Contactar.
In this part, someone who wants to contact with the author post can write his name, email and subject and send a message to the author with this three parametres + the title post (to know from which post is send this message).

But, this is just one post. I need all the posts created.

#492529

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

I've added these 2 fields to the posts and should get you the information you are looking for.

<div class='hidden-field'>
[cred_generic_field field='mail_post_title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"post_title",
"default":"[wpv-post-title]"
}
[/cred_generic_field]


[cred_generic_field field='author_email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-author format='meta' meta='user_email' ]"
}
[/cred_generic_field]

</div>


Please let me know if this helps.
Thanks,
Shane

#493153

Thank you, but my problem isn't solve.
The problem is that appears post_title created to send the message, but I need the post_title where the cred form is located

#493409

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

Could you setup back the page with the form again so that I can test it once more.

I took a look at the example page and the form isn't there anymore.

Thanks,
Shane

#493609

Sorry about that,
I change the custom post type and the url change.
Now is:
hidden link
But the problem isn't just in one post...is in all custom post....

#493712

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

I understand but if we get it to work with this post then it will work for all.

Please let me know where we are at now.

With the code i provided here.
https://toolset.com/forums/topic/i-need-to-implement-a-creed-child-notification/#post-492529

Does the author email section work where you can send the email to the author ?

Try adding a notification to send to persons email from that field and let me know.

Thanks,
Shane

#493733

Yes,
Now the only problem is that doesnt' appear the post_title where the cred form to send notification is located.

#493851

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

So we can approach this where you can add a custom field to your message CPT that will hold the parent title.

Then we just need to add that field to the form and then hide it.

Setup the custom field and then add this to your form .

[cred_generic_field field='mail_post_title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"post_title",
"default":"[wpv-post-title]"
}
[/cred_generic_field]

Changing the field name to 'wpcf-' then adding the slug of the field to the end of the wpcf-

Then just add that field to the notification.

Please let me know if this helps.

Thanks,
Shane

#494693

The problem is that the parent title is not a custom field. Is the generic post-title as well.
Then if I make what you tell me, my changes are:
[cred_generic_field field='post_title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"post_title",
"default":"[wpv-post-title]"
}
[/cred_generic_field]

and in the mail configuration:
[wpv-post-field name='post_title']

But nothing happens.

There is another way?

#494845

Shane
Supporter

Languages: English (English )

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

Hi Oriol,

The idea is to create a field on the child post to hold the parent Title.

Then you can pass the parent title of the parent to the child from the form as explain here https://toolset.com/forums/topic/i-need-to-implement-a-creed-child-notification/#post-493851

Then simply add the types shortcode for this field to your notification.

Please let me know if this is clear.

Thanks,
Shane

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