Tell us what you are trying to do?
I want to add first name(a custom user field) as the placeholder in the email notification.
I have used this doc : https://toolset.com/documentation/user-guides/how-to-use-custom-placeholders-in-cred-notifications/
My form code looks like this:
<div class="form-group">
<label>First Name<span class="asterik">*<span></label>
[cred_field field='first-name' force_type='field' class='form-control' output='bootstrap']
</div>
[cred_generic_field field='placeholder-first-name' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[[cred_field field='first-name']]"
}
[/cred_generic_field]
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification', 10, 1);
add_filter('cred_body_notification_codes', 'custom_generic_field_notification', 10, 1);
function custom_generic_field_notification( $defaultPlaceHolders ) {
$newPlaceHolders = array(
'%%FIRST_NAME%%' => $_REQUEST['placeholder-first-name']
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
I am getting the mail as this:
Hey Crusher [[[cred_field field=’first-name’]]],
Welcome to Crush Fitness India Instructure Training Program for Crush Club
Find your login credentials to login to the Instructor Training Portal
Login Credentials:
Username : beta
Password : KzWXbFx1Tl
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
Hey Waqar, anything on this?
Hi Puneet,
I'm still working on this and will update you shortly.
Thank you for your patience.
regards,
Waqar
Waiting for the same. Thanks
Hi Puneet,
Thank you for waiting and here are my findings.
Based on my tests, I can confirm that it is not possible to get the value of an existing custom field through the "cred_field" shortcode, to populate the value of a generic field.
However, good news is that you can directly get the value of that custom field from the "$_REQUEST" global variable, like this.
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification', 10, 1);
add_filter('cred_body_notification_codes', 'custom_generic_field_notification', 10, 1);
function custom_generic_field_notification( $defaultPlaceHolders ) {
$newPlaceHolders = array(
'%%FIRST_NAME%%' => $_REQUEST['wpcf-first-name']
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
This means that the hidden generic field "placeholder-first-name" is not needed for this.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Thanks Waqar. This solved my problem.