Skip to content

Instantly share code, notes, and snippets.

@gdarko
Created February 19, 2024 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdarko/25d0d8f0bcf776ed25d196bd214bb3c7 to your computer and use it in GitHub Desktop.
Save gdarko/25d0d8f0bcf776ed25d196bd214bb3c7 to your computer and use it in GitHub Desktop.
WPForms after upload hook.
<?php
/**
* Saves uploaded video through WPForms to current user meta.
*
* @param $hook_data
*
* What $hook_data contains:
*
* $hook_data = array(
* 'vimeo_title' => $vimeo_title,
* 'vimeo_description' => $vimeo_description,
* 'vimeo_id' => $vimeo_id,
* 'vimeo_size' => $file_size,
* 'source' => array(
* 'software' => 'WPForms',
* 'entry_id' => $entry_id,
* 'field_id' => $field_id,
* 'form_id' => $form_id,
* ),
* );
*
* @return void
*/
function _save_to_user_meta23423423($hook_data)
{
if ( ! is_user_logged_in()) {
return;
}
update_user_meta(get_current_user_id(), 'uploaded_video', [
'vimeo_title' => $hook_data['vimeo_title'],
'vimeo_description' => $hook_data['vimeo_description'],
'vimeo_id' => $hook_data['vimeo_id']
]);
}
add_action('dgv_frontend_after_upload_wpforms', '_save_to_user_meta23423423');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment