get user id from token in a main page

Home Forums Legacy Support Support queries Update Issues get user id from token in a main page

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #319439
    Food-interactive
    Participant
    hi Alex, i have another question about the topic you already helped successfully: ‘query in the course of the database’. you gave us the code to get the user id in a course/unit. it worked perfect :) but... it won't work in a normal page (it will work only, if admin is logged in). can you please change your code snippet, so that we can get the user id also from there (outside the course)? that would be really great :) greetings from food-interactive team
    #319703
    Anshuman Sahu
    Keymaster
    Can you please share exactly where do you want the user id , which page which module?
    #319738
    Food-interactive
    Participant
    This reply has been marked as private.
    #320161
    Anshuman Sahu
    Keymaster
    Well im sorry for this you need to be logged into wordpress . Note that as we do not handle the page content therefore we do not have our system user id available there by any means in the content . For this you need the user to be logged into wordpress login system . Note here that for the units in courses you have to use the code we provided earlier on your another topic . But for the pages you will need the user to log into wordpress login system. .
    #320197
    Food-interactive
    Participant
    This reply has been marked as private.
    #320405
    Anshuman Sahu
    Keymaster
    Im sorry to say but that is not possible .You have to follow the other tip replacing the login popup with wpp-login.php on I suggested another topic . https://wplms.io/support/forums/topic/query-in-the-course-of-the-database/page/2/#post-317476
    #320438
    Food-interactive
    Participant
    This reply has been marked as private.
    #320568
    Anshuman Sahu
    Keymaster
    Well you need both code . this one to get user id in course in which data is shown using api : add_filter( 'bp_course_api_get_user_course_status_item',function($return, $request ){ in api we do not have any get_current_user_id even though the user is logged in to wordpress login system or in our system. Now second is this : jQuery(document).ready(function(){jQuery('a.vibebp-login').on('click',function(event){event.preventDefault();event.stopPropagation();window.location.href='https://food-interactive.de/wp-login.php'});}); which is used to remove our modern login and add wordpress login is needed to get the user logged in to wordpress so that you can get this value get_current_user_id() on other pages other than which runs on api
    #320907
    Food-interactive
    Participant
    This reply has been marked as private.
    #321130
    Anshuman Sahu
    Keymaster
    because you are logged into wordpress when you login as admin . please forget the above since we have added a new setting in vibebp version 1.4.5 to sync the wp and vibebp logins : enable these both in wp-admin-> vibebp -> settings: https://prnt.sc/v7ziyc Just enable this and you will be fine .No need to change the login link and you will get the user_id.
    #321482
    Food-interactive
    Participant
    This reply has been marked as private.
Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘get user id from token in a main page’ is closed to new replies.