Support

Account

Home Forums Backend Issues (wp-admin) Update User Profile Image Reply To: Update User Profile Image

  • This is the code I am using to get updates from the user. It produces a shortcode on my /profile page for the user to make changes. I guess I would need to add something here that would make it replace the user avatar on submit?

    function my_acf_user_form_func( $atts ) {
     
      $a = shortcode_atts( array(
        'field_group' => ''
      ), $atts );
     
      $uid = get_current_user_id();
      
      if ( ! empty ( $a['field_group'] ) && ! empty ( $uid ) ) {
        $options = array(
          'post_id' => 'user_'.$uid,
          'field_groups' => array( intval( $a['field_group'] ) ),
          'return' => add_query_arg( 'updated', 'true', get_permalink() )
        );
        
        ob_start();
        
        acf_form( $options );
        $form = ob_get_contents();
        
        ob_end_clean();
      }
      
        return $form;
    }
     
    add_shortcode( 'my_acf_user_form', 'my_acf_user_form_func' );