Suggestions on how to get bbpress / wordpress username / username from cookie

I am trying to integrate my site to use the bbpress / wordpress user system.

All I need is the ability to get the username and / or user ID currently on my site. I do not need any other functions from bbpress or wordpress on the site.

If I could get the user ID, then the ability to get the user name from this ID would be ideal for all my needs.

Additional information: My site runs on PHP5 and MySQL, I have wordpress and bbpress up to date and are currently integrated with each other.

+3
source share
1 answer

Did you try to just print the contents $_COOKIE? The mine contains the following:

Array
(
    [wordpress_test_cookie] => WP Cookie check
    [wordpress_logged_in_##########] => ceejayoz|#####|##########]
)

It should be easy for you to make out.

foreach($_COOKIE as $key => $value) {
  if(preg_match('@^wordpress_logged_in_@', $key) {
    $cookie = explode('|', $_COOKIE[$key]);
    $username = $cookie[0];
  }
}
+3
source

Source: https://habr.com/ru/post/1703988/


All Articles