Tell us what you are trying to do?
I'm trying to fetch a value from a generic field to store in custom post field "student-photo"
here is the screenshot of what I'm trying to do hidden link
This is used for student photo that will serve as their Profile photo if they don't have image uploaded yet.
You need to signup first as a student then you will redirected to next registration form hidden link to select or upload photo.
Here is the generic field code we are using:
[cred_generic_field field='preset-student-profile-image' type='radio' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"persist":1,
"options":[
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"},
{"value":"hidden link","label":"<img src='hidden link' />"}
]
}
[/cred_generic_field]
I'm trying this code in functions.php
//Let the student user choose an image for their profile
add_action('cred_save_data', 'my_save_student_image',10,2);
function my_save_student_image($post_id, $form_data)
{
if ($form_data['id']==19085)
{
// Create post object
$new_post_id = wp_insert_post( array(
'post_title' => $_POST['post_title'],
'post_content' => '',
'post_status' => 'publish',
'post_author' => $post_ID,
'post_type' => 'student'
) );
// get image URL value from the user
$user_image = get_post_meta( $post_id, 'wpcf-preset-student-profile-image', true );
// if image URL exists
if (!empty($user_image)) {
// set the image URL as new post's custom field value
update_post_meta($post_id, 'wpcf-student-photo', $user_image);
// delete the image URL from user's custom field
delete_user_meta($post_id, 'wpcf-preset-student-profile-image');
}
}
}
But seems it will add another student post.
What is the link to your site? hidden link