Use WP to get the id: get_current_user_id();
Or avoid calling the bp global and use bp_loggedin_user_id()
First of all..- thx for the fast reply!
But in both cases…
… bp_loggedin_user_id(); –> CODE
… get_current_user_id(); –> CODE
I pasted in the code in line 8!
…I get an “500 Internal Server Error” and don´t know why!!!
I would really appreciate some help on this one!
thx
I’m not sure what exactly is on line 8 but make sure you use opening and closing PHP tags like this:
<?php bp_loggedin_user_id(); ?>
<?php get_current_user_id(); ?>
Thx for the advice…I already checked it!
Sorry, I didn’t see you’d posted the link to your code. I don’t think the 500 Internal Server Error is being caused by your use of those functions. Perhaps the error you’re getting is a result of code elsewhere?
but when I put in a string, instead of the bp_loggedin_user_id(); everything works just fine! So I don´t think it’s somewhere else!
Like here http://codepad.org/1KjIwqLB
get_current_user_id() returns an int. Not sure if the type in this case will make much difference but perhaps your function is expecting a string?
Try doing this:
$user_id = get_current_user_id();
$user_id = (string)$user_id;
Ref: https://codex.wordpress.org/Function_Reference/get_current_user_id
I have The Problem that my php-file doesn’t accept any
WP ore bp functions! Do I have to kind of INIT a php-file before
I can get access to the WP or BP Core…?
To explain what I mean’t, see this example:
http://codepad.org/kY1hW06z
>my php-file doesn’t accept any WP ore bp functions
Why are you trying to load it outside WP?
Write your code as a BP plugin.
Creating a Plugin
Checking For BuddyPress
thx Folks…that was the hint I needed…everythings working fine now…after I changed everything into a plugin!
Didin´t know about the PLUGIN STUFF, as I’am kind a WP-Neewbe (when it comes to programming)!