CRED is a WordPress plugin that lets you easily build front-end forms for creating and editing content and users.
CRED User Guides include detailed documentation on creating forms, including related fields that belong to the content or the users, validating the input and displaying the forms with custom HTML styling.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 376 through 390 (of 1,536 total)
The customer asked how the WordPress user "Language" field can be set through the Toolset's user form.
Solution:
Informed that there is no built-in method available in the Toolset Forms for this, so it will require some workaround and custom code.
WordPress store's the ISO language code for the user's selected WordPress admin language as a value, in the user meta field with key 'locale'.
In a user registration form, one can include a hidden generic field and fill its value with the language code of the current page's language. After that, the 'cred_save_data' hook can be used to programmatically set that selected language value into the user's 'locale' meta field:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($user_id, $form_data)
{
// if a specific form
if ($form_data['id']==1234)
{
update_user_meta( $user_id, 'locale', $_POST['locale'] );
}
}
Problem:
The user would like to customize the success message in a form before the page is redirected.
Solution:
This will require custom code snippet to customize the message that would be displayed before the redirect. Something like:
add_filter('gettext', function($translated_text, $untranslated_text, $domain){
if($untranslated_text == 'Please Wait. You are being redirected...' && $domain == 'wp-cred'){
$translated_text = 'The new message to display before the redirect';
}
return $translated_text;
}, 10, 3);
Note that the message will be wrapped in a
tag, this means that you can't use any HTML tags, only the ones that can be wrapped in a
The user wanted the custom user field values from a user ID passed through the generic field in the form notification.
Solution:
Suggested to use the "cred_subject_notification_codes" and "cred_body_notification_codes" filters to register custom placeholders for form notifications.
Example:
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 ) {
// get the user ID from the generic field 'evaluatee-user-id'
$target_user_ID = $_REQUEST['evaluatee-user-id'];
// get the first name and last name from the $target_user_ID
$user_first_name = do_shortcode("[wpv-user field='user_firstname' id='".$target_user_ID."']");
$user_last_name = do_shortcode("[wpv-user field='user_lastname' id='".$target_user_ID."']");
// set those first name and last name values in the custom placeholders
$newPlaceHolders = array(
'%%evaluatee_first_name%%' => $user_first_name,
'%%evaluatee_last_name%%' => $user_last_name,
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}