Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › how to retrieve the data of the connected user
- This topic has 8 replies, 2 voices, and was last updated 2 years, 10 months ago by Veronica.
Viewing 9 posts - 1 through 9 (of 9 total)
-
AuthorPosts
-
June 24, 2021 at 10:14 am #362635mfeijoo_294Participanthi, I need to retrieve the data of the connected user (password, id and mail), to make a call to an external application that shares the login with wplms, if the user is logged in from wordpres, the wordpress functions are ok, but if I login from wplms directly, they do not work, what solution is there for this problem?June 24, 2021 at 1:10 pm #362683mfeijoo_294ParticipantI looked for possible solutions and found that both syncs in vibeBP settings option is enabled from wp to vibe and from vibe to wp, so I don't understand why wp functions don't work to retrieve user data, for example wp_get_current_user (), the result of the user id is 0 always.June 25, 2021 at 11:30 am #362779VeronicaModeratorhi please try to use this get_current_user_id instead of wp_get_current_user function and then check I have checked this function and it is workingJune 25, 2021 at 11:40 am #362785mfeijoo_294ParticipantYes, we have tried it and sometimes it works and sometimes it doesn't, we don't understand what the problem isJune 25, 2021 at 11:46 am #362791mfeijoo_294Participantthis is the code that we tested in the funtions.php $current_user = wp_get_current_user(); $dades_usuari = get_user_by('ID', $current_user->id); $identificador = $current_user->id; echo "id usuari 1: " . $identificador; $current_user2 = wp_get_current_user(); $id_usuari2 = $current_user2->id; echo "id usuari 2: " . $id_usuari2; sometimes it works, but most of the time the result is 0 in both casesJune 26, 2021 at 8:36 am #362887VeronicaModeratorok but try to replace the wp_get_current_user to get_current_user_id function it will directly fetch the id of the user and then checkJune 26, 2021 at 11:26 pm #362979mfeijoo_294Participantok, this is the test $memberID = get_current_user_id(); echo " ** Id2: " . $memberID; if(is_user_logged_in()) {echo "*** yes **** ";} else {echo "*** NO **** ";} the result is still 0 and the user is shown as not logged in, I do not understand it, the synchronization with viveBP is activated, but it does not seem to work, we have also tried to deactivate the synchronization from Wp to viveBP and when we log in from WP, it continues Entering the viveBP menu, we do not understand what is happening, but something is wrong and it is a problem for us.June 26, 2021 at 11:41 pm #362980mfeijoo_294ParticipantWe have also tried this with the session started $urlx = "https://rcassoci-cp5022.wordpresstemporal.com/cefneapp/wp-json/wplms/v1/user/"; $chx = curl_init("${urlx}"); curl_setopt($chx, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $datax = curl_exec($chx); $objx = json_decode($datax); echo "JSON : " . $datax; curl_close($chx); But it has not yielded any results either.June 28, 2021 at 9:26 am #363054VeronicaModeratorhi it is working http://somup.com/cr1uhCqP22 check this link first please https://stackoverflow.com/questions/36113060/get-current-user-id-returning-zero-0#:~:text=This%20is%20likely%20a%20result,a%20current%20user%3B%20otherwise%200. i think this is something you need to follow
-
AuthorPosts
Viewing 9 posts - 1 through 9 (of 9 total)
- The topic ‘how to retrieve the data of the connected user’ is closed to new replies.