I\'m trying to get the current user info in my plugin using the func wp_get_current_user(). But am getting
Call to undefined function wp_get_current_user()
As crazy as this might sound, the problem in my application was happening because I had a FILE called menu.php where I had a class to create Wordpress menus.
Literally, simply changing the name of the FILE from menu.php to nav-menu.php, fixed the issue. I replicated the issue 3 times because I could not believe the name of the FILE could be the problem.
Just in case somebody would like to now what was inside that file, here it is:
class OwNavMenu extends OwCpnt
{
function __construct( $location, $args ) {
$show = $args['show'];
$span = $args['span'];
if ( $show ) {
$this->menu( $location, $span );
}
}
function menu( $location, $span ) {
if ( $location ) {
echo '';
wp_nav_menu(
array(
'theme_location' => $location,
'link_before' => ( $span ) ? '' : '',
'link_after' => ( $span ) ? '' : ''
)
);
echo '';
}
}
}