Hi,
I'm trying to load an xml file in order to read it's content and print it based on the user logged in. To do so I created a shortcode in functions.php in my child theme folder. Here's the code I wrote:
function dati_tbcrew($atts){
global $user_login;
get_currentuserinfo();
$xml=simplexml_load_file("porva.xml") or die("Error: Cannot create object");
switch($xml->name['nome']){
case $user_login: $out=$xml->name->content;break;
default:break;
}
return $out;
}
add_shortcode('dati_tbcrew', 'dati_tbcrew');
Unfortunately when I call the shortcode in a WP page it prints out "Error: Cannot create object". The XML file is in the child theme folder with functions.php. I even tried to put the server folder route in with the file's name in simplexml_load_file but it still isn't working. How can I get it working? Is it even the right procedure? Thanks in advance.