• Resolved kayapatiram

    (@kayapatiram)


    HI

    I have created Contact form 7 form in user profile page and I would like to form data to be sent to profile owner.

    Can any one help me on this? is there any code or snippet or plugin?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Vijay Hardaha

    (@vijayhardaha)

    You’ll have to tricky custom code to get this done. if you are good with coding then this page will help. otherwise, hiring a developer for this customization will be good for you.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    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,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Contact form7’ is closed to new replies.