how to retrieve the data of the connected user

Home Forums Legacy Support Support queries How-to & Troubleshooting how to retrieve the data of the connected user

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #362635
    mfeijoo_294
    Participant
    hi, 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?
    #362683
    mfeijoo_294
    Participant
    I 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.
    #362779
    Veronica
    Moderator
    hi 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 working
    #362785
    mfeijoo_294
    Participant
    Yes, we have tried it and sometimes it works and sometimes it doesn't, we don't understand what the problem is
    #362791
    mfeijoo_294
    Participant
    this 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 cases
    #362887
    Veronica
    Moderator
    ok 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 check
    #362979
    mfeijoo_294
    Participant
    ok, 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.
    #362980
    mfeijoo_294
    Participant
    We 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.
    #363054
    Veronica
    Moderator
    hi 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
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.