When a user register on Wordpress a developer is created on my Apigee organization. I achived this functionality by creating a plugin which uses wp_remote_post(). I am also able to delete account from both Wordpress and Apigee by using wp_remote_request() and specifying method DELETE. Now I want to update the acount of the user. This means that for example if a user change first name,it should be changed in both Wordpress and Apigee. From Apigee side I need to use PUT method. According to Wordpress Codes you may meet with various degrees of success when using PUT. Bellow you can see the structure of the UPDATE plugin and the body that I want to put. At the end I used a hook. In other words, when the user update his account the function do_stuff has to be executed and the data should be updated in Apigee as well.
I am not sure if that is working, because I do not know where to put the body. Any ideas?
<?php //DELETE ACCOUNT function do_stuff(){ $current_user = wp_get_current_user(); $current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) ) return; //create a recourse link $urlbegin='https://api.enterprise.apigee.com/v1/ organizations/orgname/developer s/'; $varemail= $current_user->user_email ; $url= $urlbegin.$varemail; $args = array( 'method' => 'PUT','headers'=> array( 'Authorization' => 'Basic xxxxxxxxxxxxx')); $response = wp_remote_request( esc_url_raw($url), $args ); if ( is_wp_error( $response ) ) { $error_message = $response->get_error_message(); echo "Something went wrong: $error_message"; } else { echo 'Response:<pre>'; //print_r( $response ); echo '</pre>'; } } add_action('update_profile','do_stuff'); ?> //The desired body: /*$arg_data = array('email'=> $_POST['user_email'], "firstName" =>$_POST['first_name'], "lastName" => $_POST['last_name'] , "userName" => $_POST['user_login'] );*?
Solved! Go to Solution.
Hi Vanina,
It seems like this is a preliminary question , and you've asked in more detail here. Is that right?
In which case, we don't need to answer this question. Is that right?
Hi Vanina,
It seems like this is a preliminary question , and you've asked in more detail here. Is that right?
In which case, we don't need to answer this question. Is that right?