Call to undefined function get_userdata() in plugin

Solution found: the reason was that the code including those lines were included in plug-in’s main file and were wrapped in the shortcode launch anymore.

I had to put things in another file,like for example

function load_shortcode( $atts ){
    require_once(getPluginPath().('my-project.start.php'));
}
add_shortcode( 'my-project', 'load_shortcode' );

and lines had to be in my-project.start.php


getPluginPath() is NOT a native WordPress function, don’t look for it, the only thing to know here is that it generates a path string.