In expressionengine with php parse enabled,
if i do the following, it works and i get the username displayed. logged in user is admin. So it echos out admin.
<?php
$x = '{username}';
echo $x;
?>
However if i do the following and use the{username} tag insde mkdir()
function, then it doesn't work. The directory created will have the name {username}
instead of admin. Why is this happening.
<?php
$x = '{username}';
mkdir($x);
?>
I'd suggest writing a quick plugin that accepts the logged-in username as a parameter, then does your mkdir()
work within the plugin.
class Make_directory
{
var return_data = '';
function __construct()
{
$this->EE =& get_instance();
$username = $this->EE->TMPL->fetch_param('username', FALSE);
if($username != FALSE)
{
$dir = mkdir(escapeshellarg($username));
}
$this->return_data = $dir;
}
There's more to the plugin, but that's the guts of it. Then call it like {exp:make_directory username="{logged_in_username}"}
.