Skip Navigation

[Resolved] Cred field value to pass ID of Types field to display value

This support ticket is created 7 years, 3 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 – 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 7 replies, has 2 voices.

Last updated by Shane 7 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#562541

I have a CRED Submission form which is designed to allow the public to submit a post. I am trying to set it so that the notification emails go to either the Author of the Parent Post type or the custom email field value which held in the parent post (whichever is easier).

Example of how I have tried. "tapra-profiles" is the parent post type:

Please select Parent:
[cred_field field='_wpcf_belongs_tapra-profiles_id' value='' class='form-control' output='bootstrap']

[types field='contact-email' id='_wpcf_belongs_tapra-profiles_id'][/types]

My plan was then to have a generic hidden field called "email notification" which I would then put the 'contact-email' types field into the default value. I can then select that cred field as the email notification address, but it's not working!

Thanks

James

#562555

Shane
Supporter

Languages: English (English )

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

Hi James,

Thank you for contacting our support forum.

Could you try the solution in the link below and let me know if it helps.
https://toolset.com/forums/topic/send-cred-notification-to-parent-custom-email-field/

Thanks,
Shane

#562576

Hello,

Thanks for your quick reply - always appreciated when you're tearing your hair out on something! I read on another topic that someone was trying to achieve the same thing with putting a View into the default value. I had a look at your example but i don't seem to be able to output the view successfully.

I've tried using square brackets around the view shortcode instead of in quotes and also used the single quote when defining the View name with no luck.

[cred_generic_field field='emailnotification' type='email' class='hiddenfield' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-view name="abstract-notifications"]"
}
[/cred_generic_field]
#562591

Shane
Supporter

Languages: English (English )

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

Hi James,

I see you are using double quotes within the view.

Try adding it with single quotes like this.

"default":"[wpv-view name='abstract-notifications']"

Thanks,
Shane

#562617

Hi Shane,

I already tried it with single quotes and it doesn't work as the field doesn't display at all on the front-end.

Is there anything I have to put in the view that's outputting into the value?

I have it as just the usual types field (email) and set to output raw? That's all there is in the loop.

Thanks

#562809

Shane
Supporter

Languages: English (English )

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

Hi James,

Could you try adding this to your functions.php

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output_no', 5, 2 );

function prefix_clean_view_output_no( $out, $id ) {
    if ( $id == '3463' ) {
        $start = strpos( $out, '<!-- wpv-no-start -->' );
        if ( 
            $start !== false
            && strrpos( $out, '<!-- wpv-no-end -->', $start ) !== false
        ) {
            $start = $start + strlen( '<!-- wpv-no-start -->' );
            $out = substr( $out , $start );
            $end = strrpos( $out, '<!-- wpv-no-end -->' );
            $out = substr( $out, 0, $end );
        }
    }
    return $out;
}

Replace the number 3463 with the ID of your view. What this code does is give your view a clean output.

Thanks,
Shane

#562918

Hi Shane,

Added in with correct View ID and also using single quotes (tried again with double quotes) and no luck!

Thanks,

James

#562949

Shane
Supporter

Languages: English (English )

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

Hi James,

Would you mind if I took a look at this in further detail through the backend ?

The private fields will be enabled for your next response.

Thanks,
Shane