php - Get data from registration of user with JSON API -


I just want to send data from each new user's WordPress registration to EmailTat (API API). But I do not know JSON and this document is not useful to me, can anyone help, please?

  & lt ;? Php / ** * is used to be the page that displays the registration form. * * This file is no longer used in WordPress and * is deprecated * * @ * Package * Use wp_register () to create registration link instead of @Deprected / / ('./wp-load.php' ) is required; Function register_new_user ($ user_login, $ user_email, $ nocomerce = '') {$ errors = New WP_Error (); $ User_login = sanitize_user ($ user_login); $ User_email = apply_filters ('user_registration_email', $ user_email); // Check Username ($ user_login == '') $ errors- & gt; Add ('empty_username', __ ('& strong> ERROR & lt; / strong & gt;: Please enter the username'.)); Elseif (Validate_username ($ user_login)) {$ errors- & gt; ('Invalid_username', __ ('& lt; strong & gt; ERROR & lt; / strong & gt;: This username is invalid. Please enter a valid username.');; $ User_login = ''; } Elseif (username_exists ($ user_login)) $ errors- & gt; Add ('username_exists', __ ('& lt; strong & gt; ERROR & lt; / strong & gt ;: This user name is already registered, please select another'.);; // Check the e-mail address ($ user_email == '') {$ errors- & gt; Add ('empty_email', __ ('& strong> ERROR & lt; / strong & gt;: Please type your email address')); } Elseif (! Is_email ($ user_email)) {$ errors- & gt; Add ('invalid_email', __ ('& strong> error; & lt; / strong & gt;: Email address is not correct & amp; # 8217; t.')); $ User_email = ''; } Elseif (email_exists ($ user_email)) $ errors- & gt; Add ('email_exists', __ ('& lt; strong & gt; ERROR & lt; / strong & gt;: This email is already registered, please select another')); Do_action ('register_post', $ user_login, $ user_email, $ errors); $ Errors = apply_filters ('registration_rar', $ errors); If ($ errors-> get_error_code ()) return $ errors; $ User_pass = wp_generate_password (); $ User_id = wp_create_user ($ user_login, $ user_pass, $ user_email, $ nocomerce); If (! $ User_id) {$ errors- & gt; The contact can contact you ('registerfail', sprintf (__ ('& lt; strong & gt; ERROR & lt; / strong & gt;: & amp; # 8217; t; please contact & lt; a Href = "mailto:% s"> Webmaster !), Get_option ('admin_email'))); Return $ errors; } Wp_new_user_notification ($ user_id, $ user_pass); Return $ user_id; } $ Registerfile = get_theme_root (). "/". Get_stylesheet () "/ Register.php"; Include {$ registerfile} (file_exists ($ registerfile); } Wp_redirect ('wp-register.php? Action = register'); ? & Gt;  

What should I do with it? JSON is a JavaScript Object Node, which is very easy to use with PHP: for example, If you want to pass some parameters, such as user registration, you can:

  & lt; Script & gt; // from PHP var data = & lt ;? Php echo json_encode (array ('user_login' = & gt; $ user_login, 'user_email' = & gt; $ user_email)); ? & Gt ;; Warning ("hi" + data.user_lagin + "you have email:" + data.user_email); & Lt; / Script & gt;  

Convert the function 'json_encode' into php to any object or array as a string in JSON that can be read from your JS script. I hope this will help you.

"Sorry for my English"


Comments