Hi @nchaccal
Have you tried adding a remove_cache in the hook and see if the issue still occurs?
UM()->user()->remove_cache( $user_id );
Regards,
Sorry for the noob question, but where do i need to put it? At the start of the code or at the end?
This is more or less my code (which its work, but only if you edit profile twice). I use wp_remote_request with a put method:
function edit_profile( $args ) {
$body = [
'first_name' => um_user(first_name),
'last_name' => um_user('last_name'),
'phone' => um_user('phone'),
'email' => um_user('email'),
];
$body = wp_json_encode( $body );
$options = [
'body' => $body,
'headers' => [
'Content-Type' => 'application/json',
],
'method' => 'PUT',
'timeout' => 60,
'redirection' => 5,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
'data_format' => 'body',
];
$response = wp_remote_request( 'https://xxxxxxxxxxxx.xxxx.xxx', $options );
UM()->user()->remove_cache( $user_id );
}
add_action( 'um_after_user_updated', 'edit_profile', 10, 2 );
Thanks in advance! π
Hi @nchaccal
Please try this one:
function edit_profile( $args ) {
// Remove cache
UM()->user()->remove_cache( um_user('ID') );
$body = [
'first_name' => um_user('first_name'),
'last_name' => um_user('last_name'),
'phone' => um_user('phone'),
'email' => um_user('email'),
];
$body = wp_json_encode( $body );
$options = [
'body' => $body,
'headers' => [
'Content-Type' => 'application/json',
],
'method' => 'PUT',
'timeout' => 60,
'redirection' => 5,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
'data_format' => 'body',
];
$response = wp_remote_request( 'https://xxxxxxxxxxxx.xxxx.xxx', $options );
}
add_action( 'um_after_user_updated', 'edit_profile', 10, 2 );
Regards,
Hi!
Thanks for the code. But unfortunately nothing changed.
I tried with the original user edit of wordpress and works fine. The thing is when i try to make changes from the UM profile editor.
Any other idea?
Thanks again for your collaboration and sorry for bother you with this.
Hi @nchaccal
Try changing the action hook priority from 10 to 1. Also remove the 2 from the parameter as you’re only using the first parameter in the function.
e.g. add_action( 'um_after_user_updated', 'edit_profile', 1 );
Regards,
Hi again!
Sorry, I really don’t want to be a bother, but nothing has changed yet.
I’ll keep trying to make it work.
If you have another idea in mind, please let me know.
BTW, i note that if, for example, i change the first_name for another one in the first time nothing happen, but, when i do it for a second time with a different first_name, it will change to the option that i put at the first try. It’s very strange. I dont know if there a queque or something.
My debug console does not show anything related with the HTTP PUT Method.
Thanks for your time. I really appreciate it.
EDIT:
I solved it.
I had to put this at first of my function (which i dont know well what it does lol):
global $ultimatemember;
um_fetch_user( um_user('ID') );
Thanks for your help and your concern in my case π
-
This reply was modified 5 years, 6 months ago by
Nicolas.
-
This reply was modified 5 years, 6 months ago by
Nicolas.