SHARE
TWEET

Untitled

a guest Aug 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pw_rcp_save_user_fields_on_register( $posted, $user_id ) {
  2.     echo "<script type='text/javascript'>alert('submitting user info');</script>";
  3.     $message = $posted['rcp_user_company'];
  4.     echo "<script type='text/javascript'>alert('$message');</script>";
  5.        
  6.     if( ! empty( $posted['rcp_profession'] ) ) {
  7.         update_user_meta( $user_id, 'profession', sanitize_text_field( $posted['rcp_profession'] ) );
  8.     }
  9.    
  10.     if( ! empty( $posted['rcp_bio'] ) ) {
  11.         update_user_meta( $user_id, 'description', sanitize_text_field( $posted['rcp_bio'] ) );
  12.     }
  13.    
  14.     if( ! empty( $posted['rcp_user_company'] ) ) {
  15.         $company = pods( 'company', $posted['rcp_user_company'] );
  16.        
  17.         // This is in the PHP file and sends a Javascript alert to the client
  18.         $message = $posted['rcp_user_company'];
  19.         echo "<script type='text/javascript'>alert('$message');</script>";
  20.        
  21.         if ( ! $company->exists() ) {
  22.  
  23.             $companyPod = pods( 'company' );
  24.  
  25.             $data = array(
  26.                 'name' => $posted['rcp_user_company']
  27.             );
  28.  
  29.             $companyPod->add( $data );
  30.             $company = pods( 'company', $posted['rcp_user_company'] );
  31.         }
  32.        
  33.         $data = array(
  34.             'company'  => $company ,
  35.         );
  36.         $userPod = pods( 'user', get_current_user_id() );
  37.         $userPod->save($data);
  38.     }
  39. }
  40. add_action( 'rcp_form_processing', 'pw_rcp_save_user_fields_on_register', 10, 3 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top