@redhat894 thank you for reaching out.
I have tested and by sending media_id
value in the simple_local_avatar
object, I was able to update the Avatar image. Can you please share how you are sending the request?
-
This reply was modified 1 year, 10 months ago by
Faisal Alvi.
@faisal03 I got this, I didn’t wrap the media_id
in simple_local_avatar
before, now it’s working.
Thanks.
Hello @faisal03 ,
So a sample rest api call to post by sending media_id
value in the simple_local_avatar.
will look like? Because I believe a sample code will go a long way to assist other users who need this like myself.
great plugin by the way.
@msowah the following is the sample request call in PHP, sending a media_id
value in the simple_local_avatar
.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://mysite.local/wp-json/wp/v2/users/1/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"simple_local_avatar": {
"media_id": 9218
}
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Basic YWFais46bzlAvlVdCBrdVlnIGxPRTAgOG1ycCBiMzBzIFJYSEg=',
'Content-Type: application/json',
'Cookie: woocommerce_multicurrency_forced_currency=INR; woocommerce_multicurrency_language=en'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;