Skip Navigation

[Gelöst] CRED form is not showing from which page the inquiry has been posted

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: I have a CRED form that appears on a custom post type single post. When the CRED form is submitted, I have an email notification set up. In this notification, I would like to include a link to the single post page.

Solution: Use generic fields in your CRED form to capture the current page title and link:

[cred_generic_field field='currentpagetitle' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-title id='$current-page']"
}
[/cred_generic_field]

[cred_generic_field field='currentpageurl' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-url id='$current-page']"
}
[/cred_generic_field]

- Add the following code to functions.php to enable your custom placeholders:

function custom_generic_field_notification( $defaultPlaceHolders ) {
 
    $newPlaceHolders = array(
        '%%FORCED_PARENT_TITLE%%' => $_REQUEST['currentpagetitle'],
        '%%FORCED_PARENT_URL%%' => $_REQUEST['currentpageurl']
    );
    return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

- Add the title and link placeholders to your email:

<a href="%%FORCED_PARENT_URL%%">%%FORCED_PARENT_TITLE%%</a>

Relevant Documentation: https://toolset.com/documentation/user-guides/how-to-use-custom-placeholders-in-cred-notifications/

This support ticket is created vor 7 Jahre. 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)

Author
Artikel
#513707

I am trying to send a notification to the admin about a CRED form filled on the website. I have created a notification in CRED which delivers the details the user fills up in the front end.
I have included %%POST_PARENT_LINK%% to know from which page the form has been filled up. It was working fine sometime back. But, currently I am receiving all the details but %%POST_PARENT_LINK%% is empty. I am unable to track this info.
I haven't made any changes to the form. I had updated the plugins.
As I am working on listings website, it is important to know, on which page the inquiry was posted.
Please resolve. Thank You

#513839

Hi, if I understand correctly you would like to get the name of the page from which the CRED form was submitted, correct? Can you try using the following code:

[wpv-post-link id="$current-page"]

Please replace the %%POST_PARENT_LINK%% placeholder with this shortcode to access the name of the page where the CRED form is placed.

#514616

Sorry for the late reply.
I tried incorporating your code. I got the following in the notification mail

This e-mail was sent when your contact form on this page was filled
CRED Auto Draft 45679e4a4e3125cf2a265b4488e1a53a

Please help me resolve this.
Thanks and Regards

#514941

Hi, I believe this problem is related to a bug that has already been reported to our developers. While they are working on a permanent fix, I can provide a temporary solution for you. Please add the following code to your theme's functions.php file:

// custom cred notification placeholders
add_filter('cred_body_notification_codes', 'custom_generic_field_notification');
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification');

function custom_generic_field_notification( $defaultPlaceHolders ) {

    $newPlaceHolders = array(
        '%%FORCED_PARENT_TITLE%%' => $_REQUEST['currentpagetitle']
    );

    return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

Then edit your CRED form and add the following code just before the submit button at the bottom of the form code:

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

Please try this workaround and let me know if it resolves the parent page title placeholder problem you are experiencing.

#515949

Sorry for the late reply.
Here's what I got after I implemented your code.

This e-mail was sent when your contact form on this page was filled
CRED Auto Draft 45679e4a4e3125cf2a265b4488e1a53a

#516289

Okay I see. In that case, I would like to take a closer look in your wp-admin area. Please provide login credentials here in the private reply fields. If I need to make adjustments, I will create a clone of your site using the Duplicator plugin:
https://wordpress.org/plugins/duplicator/

Then I can install the site locally and run tests or tweak settings without breaking your live site. If this is okay, please provide the login credentials so I can get started.

#517802

Thank you very much for the support. I am sorry for the late reply.

#517961

Thank you, may I ask what URL I can visit to fill out the form that triggers your email notification?

#518048

hidden link

Please fill the form below the listing.
Thank You

#518731

Hi, I've been reviewing your site and I think that you can make these changes to see the parent post title correctly displayed in your email notification:
- Enable the Directory Starter theme
- Edit your email notification to use the '$current-page' operator in the generic field's post title value:

[cred_generic_field field='currentpagetitle' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-title id='$current-page']"
}
[/cred_generic_field]

- Add the title placeholder to your email: %%FORCED_PARENT_TITLE%%

This should add the parent post's title to your email notification. Please let me know if I can be of further assistance.

#519594

As I do not understand coding well, please help.

Where should I paste %%FORCED_PARENT_TITLE%%? Is it the in the body of the e mail notification?
Also please see that the form below the listing is generating the name of the preschool (at the end). It was supposed to be hidden. Please check the below link.
hidden link

Thank you so much.

#519794
Screen Shot 2017-05-03 at 8.51.41 AM.png

Yes, you should paste %%FORCED_PARENT_TITLE%% anywhere you want to include the name of the preschool in the body of your email notification.

It looks like there was a problem copy + pasting the content of your generic form field. Please see the attached screenshot of your CRED form here:
/wp-admin/post.php?post=27&action=edit

The single quotes were replaced with ASCII codes. I'm not exactly sure how that would have happened, but it's an easy fix. I've changed those in your CRED form to use proper single quotes, and this field is now hidden. Please let me know if I can help with anything else here.

#520045
check1.png
check.png

I am almost there. Thank you for your patience. I am currently getting the name of the preschool. But, I am unable to get the link to the listing. Please check the snapshots to see what I have done and the result in my inbox.

#520254

Okay, for some reason I thought you only needed the title. We can make a modification in functions.php to add to your new placeholders array:

function custom_generic_field_notification( $defaultPlaceHolders ) {

    $newPlaceHolders = array(
        '%%FORCED_PARENT_TITLE%%' => $_REQUEST['currentpagetitle'],
        '%%FORCED_PARENT_URL%%' => $_REQUEST['currentpageurl']
    );
    return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

In your CRED form, add another generic field:

[cred_generic_field field='currentpageurl' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-url id='$current-page']"
}
[/cred_generic_field]

Then in your email notification, add a link like this:

<a href="%%FORCED_PARENT_URL%%">%%FORCED_PARENT_TITLE%%</a>

Let me know how it goes, thanks!

#520498

Thanks a lot for your support. I have achieved what I needed. I am sure this will be much easier to do in later versions of CRED as requiring to show the page from where the form has been filled is a common requirement. I appreciate your support towards a non-coder. Thank you very much.

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