PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Update user meta with value processed in form submition

  1. brubrant2
    Member

    I need to run the function wp_handle_upload() on file sent by form contain file field, and then use returned value of this function to update the meta user after registered.

    In addition to several other attempts my last were:

    add_action("gform_after_submission_5", "v5_armazena_avatar");
    function v5_armazena_avatar() {
    	global $avatar;
    	$avatar = wp_handle_upload( $_FILES['input_5'], array( 'test_form' => false ) );
    }
    
    add_action("gform_user_registered", "v5_atualiza_avatar", 10 );
    function v5_atualiza_avatar($user_id) {
    	global $avatar;
    	update_user_meta( $user_id, 'simple_local_avatar', array( 'full' => $avatar['url'] ) );
    }

    Currently the custom meta user is stored with value: a:1:{s:4:"full";s:0:"";}

    The problem is that I do not know at wich hook I have access to the global PHP $ _FILES.

    I also tried gform_pre_submission hook.

    Any thoughts will be appreciated.

    Thanks.

    Posted 11 years ago on Saturday September 15, 2012 | Permalink
  2. As a troubleshooting step, can you dump the $_FILES array with both the gform_pre_submission and gform_after_submission hook to see what it contains?

    Posted 11 years ago on Sunday September 16, 2012 | Permalink
  3. brubrant2
    Member

    Hi Chris,

    when tested at gform_pre_submission hook then started to work, pretty weird, but great, I got what I wanted.

    Thank you for your attention!

    Regards.

    Posted 11 years ago on Sunday September 16, 2012 | Permalink
  4. Glad you were able to work it out. Nice customization.

    Posted 11 years ago on Sunday September 16, 2012 | Permalink

This topic has been resolved and has been closed to new replies.