Thanks for the positive feedback. Unfortunately, I strip periods out for other security reasons. You have a couple of options.
1) Use a different dynamic path, like fa-firstlast
2) Create a little shortcode of your own to strip out periods like so:
class my_fileaway_extension
{
public function __construct()
{
add_shortcode('fileaway_extended', array($this, 'sc'));
}
public function sc($atts = array())
{
if(!class_exists('fileaway') || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array('.',"'",'"'), '', $u->user_login);
if(isset($atts['sub'])) unset($atts['sub']);
$atts['sub'] = 'fa-userrole/'.$login;
$fileaway = new fileaway;
return $fileaway->sc($atts);
}
}
new my_fileaway_extension;
Put that class in your theme’s functions.php, or in your own plugin if you know how to do that. The function above removes periods, apostrophes and double-quotes from the username string before it passes it to file away.
Then replace your current shortcode on your page with this:
[fileaway_extended fadein="opacity" makedir="true" fadetime="500" theme="silk" manager="on" name="files" password="pass" user_override="fa-userid"]
We’ve removed the sub attribute from the shortcode because we handle that in our custom php function. We’ve also removed the bulkdownload attribute, because it’s redundant with manager mode enabled. We’ve also removed the type=”table” attribute, because with manager mode enabled, that’s a given.
If you need to do it with File Up as well, ditch the above code and replace it with this:
class my_fileaway_extension
{
public function __construct()
{
add_shortcode('fileaway_extended', array($this, 'sc'));
add_shortcode('fileup_extended', array($this, 'up'));
}
public function sc($atts = array())
{
if(!class_exists('fileaway') || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array('.',"'",'"'), '', $u->user_login);
if(isset($atts['sub'])) unset($atts['sub']);
$atts['sub'] = 'fa-userrole/'.$login;
$fileaway = new fileaway;
return $fileaway->sc($atts);
}
public function up($atts = array())
{
if(!class_exists('fileup') || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array('.',"'",'"'), '', $u->user_login);
if(isset($atts['sub'])) unset($atts['sub']);
$atts['sub'] = 'fa-userrole/'.$login;
$fileup = new fileup;
return $fileup->sc($atts);
}
}
new my_fileaway_extension;
Then use [fileaway_extended] and [fileup_extended] with all your ordinary attributes except for the sub attribute.
Thx for your quick response. I placed the new class in my themes functions.php but it doesn’t seem to register the new shortcode. I replaced the old shortcode with the new “fileaway_extended” and it displays the uninterpreted shortcode on the page.
Well, it should work fine. Be sure you include it after the opening <?php tag in the functions.php (obviously). You did include the last line:
new my_fileaway_extension;
right?
Do you have more than one functions.php?
Would you mind pasting the code here that you pasted there exactly for me?
class my_fileaway_extension
{
public function __construct()
{
add_shortcode(‘fileaway_extended’, array($this, ‘sc’));
}
public function sc($atts = array())
{
if(!class_exists(‘fileaway’) || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array(‘.’,”‘”,'”‘), ”, $u->user_login);
if(isset($atts[‘sub’])) unset($atts[‘sub’]);
$atts[‘sub’] = ‘fa-userrole/’.$login;
$fileaway = new fileaway;
return $fileaway->sc($atts);
}
}
new my_fileaway_extension;
It’s only one functions.php, and yes, it is between php tags
If all else fails, remove it from your functions.php, then create a blank document in Notepad, and paste this in:
<?php
/*
** Plugin Name: File Away Extended
** Plugin URI: http://ww.wp.xz.cn/plugins/file-away/
** Description: My File Away Add-On
** Version: 1
** Author: Felix
*/
class my_fileaway_extension
{
public function __construct()
{
add_shortcode('fileaway_extended', array($this, 'sc'));
add_shortcode('fileup_extended', array($this, 'up'));
}
public function sc($atts = array())
{
if(!class_exists('fileaway') || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array('.',"'",'"'), '', $u->user_login);
if(isset($atts['sub'])) unset($atts['sub']);
$atts['sub'] = 'fa-userrole/'.$login;
$fileaway = new fileaway;
return $fileaway->sc($atts);
}
public function up($atts = array())
{
if(!class_exists('fileup') || !is_user_logged_in()) return;
$u = wp_get_current_user();
$login = str_replace(array('.',"'",'"'), '', $u->user_login);
if(isset($atts['sub'])) unset($atts['sub']);
$atts['sub'] = 'fa-userrole/'.$login;
$fileup = new fileup;
return $fileup->sc($atts);
}
}
new my_fileaway_extension;
save it as: fileaway-extended.php
uploaded it to a folder that you’ll create like so:
wp-content/plugins/fileaway-extended/
Then go to your plugins page and activate your new plugin.
Or, you could give me access and I’ll figure out what the hangup is.
Ok, now it works, but the problem is that the extended plugin function removes the dot while the uploader uses the users name as it is (with dot included), so I still have 2 different folders (test.test and testtest). Would it be posible for the manager to use the users name as it is (dot included)?
You mean you’re using a different uploader than File Up? You didn’t mention that.
No, no, the file up I mean.
[fileup sub=”/fa-userrole/fa-username” makedir=”true” theme=”silver-bullet”]
[fileaway_extended fadein=”opacity” makedir=”true” fadetime=”500″ theme=”silk” bulkdownload=”on” manager=”on” name=”files” password=”wp!@#$%^” user_override=”fa-userid”]
These are the 2 shortcodes I’m currently using.
The code I provided you has a new shortcode for both File Away and File Up, as I mentioned several comments back:
[fileup_extended makedir=”true” theme=”silver-bullet”]
[fileaway_extended fadein=”opacity” makedir=”true” fadetime=”500″ theme=”silk” bulkdownload=”on” manager=”on” name=”files” password=”wp!@#$%^” user_override=”fa-userid”]
The first code block I pasted did not have a File Up extended shortcode. The next two do. Re-read the third comment of the thread.
oh, sorry, I missed that. Just a sec
Ok, now it works. But what happens if at some point there will be 2 users, one testtest and the other one test.test . Wouldn’t that result in mixing their files?
Yes, that’s a good point. If two users with the same role have the same login except for periods, then yeah, it’ll point to the same directory. We can modify this to include the user id in the directory path, if you want to do that. Want me to modify the code to include the user id?