Hi @kayapatiram
You can try this code snippet to send the email to the current viewing profile:
add_filter( 'wpcf7_mail_components', 'um_020821_change_email_to_profile_owner_email' );
function um_020821_change_email_to_profile_owner_email( $args, $contact_form, $class){
if ( class_exists( '\WPCF7_Submission' ) ) {
$submission = \WPCF7_Submission::get_instance();
$page = $submission->get_meta( 'container_post_id' );
if ( intval( UM()->options()->get( 'core_user' ) ) == intval( $page ) ) {
if ( ! empty( $_REQUEST['_wpcf7_um_profile_id'] ) ) {
$user = get_user_by( 'ID', absint( $_REQUEST['_wpcf7_um_profile_id'] ) );
if ( ! is_wp_error( $user ) && isset( $user->user_email ) && is_email( $user->user_email ) ) {
$args['recipient'] = $user->user_email;
}
}
}
}
return $args;
}
add_filter( 'wpcf7_form_hidden_fields', 'um_020821_add_profile_id_on_cf7' );
function um_020821_add_profile_id_on_cf7( $fields ){
if ( um_is_core_page( 'user' ) ) {
$fields['_wpcf7_um_profile_id'] = um_profile_id();
}
return $fields;
}
Ensure that the user page is set in the WP Admin > UM > Settings > General > Pages > User page.
You can add the code snippet to your theme/child-theme’s functions.php file or use the Code Snippet plugin to run the code.
Regards,