Here is a little piece of code that I implemented to get User ID and Role:
add_filter('jwt_auth_token_before_dispatch', 'add_user_id_and_role_to_jwt_response', 10, 2);
function add_user_id_and_role_to_jwt_response($data, $user) {
// Aggiungi il campo 'user_id' al JSON della risposta
$data['user_id'] = $user->data->ID;
// Ottieni il ruolo dell'utente
$user_roles = $user->roles;
$user_role = !empty($user_roles) ? $user_roles[0] : '';
// Aggiungi il campo 'user_role' al JSON della risposta
$data['user_role'] = $user_role;
// Restituisci il nuovo array dati modificato
return $data;
}
]]>I hope it will help you in the next update
Thank you very much for your efforts and for programming this plugin!
All the best,
WebAlchLAB Team
]]>recently I was testing woocommerce API and trying to build a flutter app when I tried to
access local WordPress woocommerce site through my developed application
“Sorry, you are not allowed to create resources.”
even after entering the customer key and secret why i can’t authenticate do i need to do any special configuration for local?
Thank you very much in advance
]]>I am creating a flutter app which uses the WooCommerce Rest Api to display products and stuff. The problem is that I have added the add to cart functionality but when I want to display the current cart of the user, I am using the <my-domain>/wp-json/wc/v3/cart?user_id=8&consumer_key=mykey&consumer_secret=mysecretkey and the json response I am getting contains the user ID in the beginning like that: 6{“status”:true,”data”:[]}.
Is this a problem from the WooCommerce side? Because I shouldn’t receive the user_id before the JSON response.
Please help and thank you.
]]>I have set up woocomerce with yith request a quote and i am trying to work out how to get it to work on an app i am developing on flutter, i am using rest api but i cant figure out the route to use to make the request a quote button to work on the app and i would also like to replace the cart with the quote list and the cart with the page to send the request.
]]>I have a flutter application which is using FCM for push notifications.
When I sent a push notification from the firebase dash it does display in app.
However when I send a test messaging from this plugin I get the following errors:
{“headers”:{},”body”:”{\”error\”:\”InvalidParameters: Bad topic or filter provided\”}”,”response”:{“code”:200,”message”:”OK”},”cookies”:[],”filename”:null,”http_response”:{“data”:null,”headers”:null,”status”:null}}
perhaps I am setting the plugin settings up wrong.
I have used my firebase project server key for api key. The topic that is configured in the app which in my case is: “One Track Mind Magazine”
for application channel I added this code to my android manifest:
<meta-data android:name=”com.google.firebase.messaging.default_notification_channel_id”
android:value=”app_channel”/>
and I’m using “app_channel” as channel name.
Any ideas what I am doing wrong?
]]>