Advertisement
Guest User

Gravity &nbsp

a guest
Dec 12th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. add_action( 'gform_pre_submission_36', 'pre_submission_handler2' );
  2. function pre_submission_handler2( $form ) {
  3. global $wpdb;
  4. if ( is_user_logged_in() ) {
  5. $user = wp_get_current_user();
  6. $u_id = $user->ID;
  7. $user_meta=get_userdata($u_id);
  8. $user_roles=$user_meta->roles;
  9. if (in_array('sp_trainer', $user_roles))
  10. {
  11. $post_type = 'dog_training_provide';
  12. }
  13. elseif(in_array('sp_adoption', $user_roles))
  14. {
  15. $post_type = 'dog_adoption_provide';
  16. }
  17. elseif(in_array('sp_groomer', $user_roles))
  18. {
  19. $post_type = 'dog_grooming_provide';
  20. }
  21. elseif(in_array('sp_veterinarian', $user_roles))
  22. {
  23. $post_type = 'dog_health_provider';
  24. }
  25. elseif(in_array('sp_daycare', $user_roles))
  26. {
  27. $post_type = 'dog_day_care_provide';
  28. }
  29. else
  30. {
  31. $post_type = 'demo_test';
  32. }
  33. $args = array(
  34. 'author' => $u_id,
  35. 'orderby' => 'post_date',
  36. 'order' => 'DESC',
  37. 'post_type' => $post_type,
  38. 'posts_per_page' => 1
  39. );
  40. $the_query = new WP_Query($args) ;
  41. if ($the_query->have_posts()) {
  42. while ( $the_query->have_posts() )
  43. {
  44. $the_query->the_post();
  45. //update_post_meta( get_the_ID(), 'profile_title', $_POST['input_7'] );
  46. update_post_meta( get_the_ID(), 'profile_description', $_POST['input_8'] );
  47. update_post_meta( get_the_ID(), 'lead_sub_title', $_POST['input_1'] );
  48. update_post_meta( get_the_ID(), 'profile_key1', $_POST['input_2'] );
  49. update_post_meta( get_the_ID(), 'profile_key2', $_POST['input_4'] );
  50. update_post_meta( get_the_ID(), 'profile_key3', $_POST['input_3'] );
  51. update_post_meta( get_the_ID(), 'profile_key4', $_POST['input_5'] );
  52. update_post_meta( get_the_ID(), 'appointment_setting', $_POST['input_7'] );
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement