Skip Navigation

[Resolved] Adding custom user field as a placeholder in user-form

This support ticket is created 5 years, 5 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by puneetS-3 5 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1297341

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?

#1297355
#1297537

Hey Waqar, anything on this?

#1297545

Hi Puneet,

I'm still working on this and will update you shortly.

Thank you for your patience.

regards,
Waqar

#1297577

Waiting for the same. Thanks

#1297663

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

#1297707

Thanks Waqar. This solved my problem.