Skip Navigation

[Resolved] Split: Custom Search For Users View Alternative

This support ticket is created 6 years, 4 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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1090503

Amr

Thank you for your reply and answers. I do however have a related question.

At registration time, using a CRED user form, we capture a user spoken languages using Checkboxes custom field. We then pass the selected values to the related CPT record that we create on the fly using the "cred_save_data" hook. In the CPT record, we have a similarly defined Checkboxes custom field to store the languages. The challenge we are facing is that, we are passing the values of the "user language meta field" to the "CPT language meta field" exactly "as is" using the following:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{

if ($form_data['id']==xxx)
{
$user = get_user_by( 'id', $post_id );
$userlogin = $user->user_login;
$useremail = $user->user_email;
$languagestaught = get_user_meta($post_id, 'wpcf-languages-taught', true);

$new_post = array(

'post_type' => 'profile-archive',
'post_status' => 'publish',
'post_title' => $userlogin,
'post_author' => $post_id,
'meta_input' => array(
'wpcf-user-languages-taught' => $languagestaught,
),
);

wp_insert_post($new_post);
}
}

Because of the way Types store checkboxes in a serializes array, when passing the values selected from one checkboxes field to another checkboxes field, it does not work event if the field definition values are the same. See:

This the value that we store in the "user meta language checkboxes field":
a:2:{s:64:"wpcf-fields-checkboxes-option-88f76ae1b2b521ccc00621105a81acac-1";a:1:{i:0;s:6:"Arabic";}s:64:"wpcf-fields-checkboxes-option-7c065902a604d2aa9fc72a0914116677-1";a:1:{i:0;s:4:"Dari";}}

This the value that is expected to be stored in the "CPT meta language checkboxes field" for it to work:
a:2:{s:64:"wpcf-fields-checkboxes-option-c954607b4f3c4a21a3bb8f53e425673d-1";a:1:{i:0;s:6:"Arabic";}s:64:"wpcf-fields-checkboxes-option-4b696a1d773874edd1117e2e87e775b9-1";a:1:{i:0;s:4:"Dari";}}

When we straight copy the value of the "user meta language checkboxes field" into the "CPT meta language checkboxes field", it does not work since the wpcf-fields-checkboxes-option- are different.

Is there a way to read the array values from the "user meta language checkboxes field" and write those same values to the "CPT meta language checkboxes field" when a CRED user form is submitted.

Thank you.

#1091117

Hello,

It needs custom PHP codes, please provide a database dump file(ZIP file) of your website in below private detail box, also point out the problem user form URL and page URL, I need to test and debug it in my localhost, thanks