Yeah, it does not relate to the plugin.
I guess, When you upload an attachment on front end, there is no post ID. So, it needs a little tricky way.
At first, set a particular post to an upload button.
wp_enqueue_media( array( 'post' => $post->ID )); // upload file to submitpage
And, write these functions in your functions.php.
<?php
function tempo_id_for_frontend( $attachment_id ){ // run after an attachment is added to the DB
global $post;
$user_id = get_current_user_id();
$submit_id = get_page_by_path( 'submitpage' )->ID;
$attachment = get_post( $attachment_id );
if ( $attachment->post_parent == $submit_id && $user_id ){
$tempo_ids = get_post_meta( $submit_id, 'id_for_frontend', true); // set attachment ID in the customfield of "submitpage"
if( !$tempo_ids ) $tempo_ids = array();
$tempo_ids = $tempo_ids += array( $attachment_id => $user_id );
update_post_meta( $submit_id, 'id_for_frontend', $tempo_ids );
}
return $attachment_id;
}
add_filter( 'add_attachment', 'tempo_id_for_frontend', 99, 2 );
function save_post_for_frontend ( $post_id ) {
if ( !is_admin() ){
$user_id = wp_get_current_user()->ID;
$submit_id = get_page_by_path( 'submitpage' )->ID;
if( get_post_type( $post_id ) === 'your_custom_post_type_here' && $user_id ){ // set "post", "page", or your custom posttype
$tempo_ids = get_post_meta( $submit_id, 'id_for_frontend', true);
if( $tempo_ids ) : foreach ($tempo_ids as $key => $val ) : // pick attachment IDs from the customfield
if ( $val == $user_id ){
$at_post = array();
$at_post['ID'] = $key;
$at_post['post_parent'] = $post_id; // set post_parent
wp_update_post( $at_post );
}
unset( $tempo_ids[$key] );
endforeach; endif;
if( $tempo_ids ) update_post_meta( $submit_id, 'id_for_frontend', $tempo_ids );
else delete_post_meta( $submit_id, 'id_for_frontend' );
}
}
}
add_action( 'save_post', 'save_post_for_frontend' );
?>