Created
November 4, 2015 14:44
-
-
Save greenhornet79/349888be86df779de681 to your computer and use it in GitHub Desktop.
How to use the leaky_paywall_new_subscriber action to do something with the new user data after they are added to the WordPress user table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // use the leaky_paywall_new_subscriber action to do something with the new user data after they are added to the WordPress user table | |
| add_action( 'leaky_paywall_new_subscriber', 'lp_add_new_user_to_third_party_api', 20, 5 ); | |
| function lp_add_new_user_to_third_party_api( $user_id, $email, $meta, $customer_id, $meta_args ) { | |
| // replace with the specific API data needed by your third party system (mailchimp, emma, etc.) | |
| $api_key = 'yourkeyhere'; | |
| $url = 'https://www.yourapiurl.com/resourcepath?key=' . $api_key; | |
| // replace args with the data and format that is needed by your third party API | |
| $args = array( | |
| 'method' => 'POST', | |
| 'timeout' => 45, | |
| 'redirection' => 5, | |
| 'httpversion' => '1.0', | |
| 'blocking' => true, | |
| 'body' => json_encode( | |
| array( | |
| 'email_address' => $email, | |
| ) | |
| ), | |
| 'cookies' => array() | |
| ); | |
| // send data to third party API | |
| $response = wp_remote_post( $url, $args ); | |
| // return the response so you can perform an action based on the result of the API call | |
| return $response; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment