um_admin_do_action__duplicate_form

The Ultimate Member um admin do action duplicate form function.

Description

um_admin_do_action__duplicate_form( $action ); 

Parameters (1)

0. $action
The action.

Usage

  1. if ( !function_exists( 'um_admin_do_action__duplicate_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ultimate-member/admin/core/um-admin-actions.php'; 
  3.  
  4. // The action. 
  5. $action = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = um_admin_do_action__duplicate_form($action); 
  9.  

Defined (1)

The function is defined in the following location(s).

/admin/core/um-admin-actions.php  
  1. function um_admin_do_action__duplicate_form( $action ) { 
  2. global $ultimatemember; 
  3. if ( !is_admin() || !current_user_can('manage_options') ) die(); 
  4. if ( !isset($_REQUEST['post_id']) || !is_numeric( $_REQUEST['post_id'] ) ) die(); 
  5.  
  6. $post_id = $_REQUEST['post_id']; 
  7.  
  8. $n = array( 
  9. 'post_type' => um_form,  
  10. 'post_title' => sprintf(__('Duplicate of %s', 'ultimatemember'), get_the_title($post_id) ),  
  11. 'post_status' => 'publish',  
  12. 'post_author' =>um_user'ID'),  
  13. ); 
  14.  
  15. $n_id = wp_insert_post( $n ); 
  16.  
  17. $n_fields = get_post_custom( $post_id ); 
  18. foreach ( $n_fields as $key => $value ) { 
  19.  
  20. if ( $key == '_um_custom_fields' ) { 
  21. $the_value = unserialize( $value[0] ); 
  22. } else { 
  23. $the_value = $value[0]; 
  24.  
  25. update_post_meta( $n_id, $key, $the_value ); 
  26.  
  27.  
  28. delete_post_meta($n_id, '_um_core'); 
  29.  
  30. $url = admin_url('edit.php?post_type=um_form'); 
  31. $url = add_query_arg('update', 'form_duplicated', $url); 
  32.  
  33. exit( wp_redirect( $url ) ); 
  34.