WordPress.org

Ready to get started?Download WordPress

Forums

BP Group Documents
[resolved] Time in filename (5 posts)

  1. eliongater
    Member
    Posted 3 months ago #

    When i download a file it has the unix time in the filename. How can i change this?
    Thanks

    https://wordpress.org/plugins/bp-group-documents/

  2. lenasterg
    Member
    Plugin Author

    Posted 3 months ago #

    Actually you can't unless you change the plugin code.
    The time is there to avoid having files with the exact same filename.

  3. eliongater
    Member
    Posted 3 months ago #

    Ah ok that makes sense. If I was to change the code, what would I change?

  4. lenasterg
    Member
    Plugin Author

    Posted 3 months ago #

    You have 2 options:
    1. This is the recommented.
    In your custom.php or theme functions.php
    use the following:

    remove_filter('bp_group_documents_filename_in', 'bp_group_documents_prepare_filename');
    add_filter('bp_group_documents_filename_in', 'your_function_for_prepare_filename');
    
    function your_function_for_prepare_filename($file){
    $file = SOMETHING INSTEAD OF TIME() . '-' . $file;
        $file = preg_replace('/[^0-9a-zA-Z-_.]+/', '', $file);
        return $file;
    }

    2. NOT Recommended because in the next plugin update you will lose the change.
    Plugin's file /includes/filters.php
    in function bp_group_documents_prepare_filename()
    line 15 change the time()
    $file = time() . '-' . $file;
    to what ever you want.

    Bests Lena

  5. eliongater
    Member
    Posted 3 months ago #

    Thanks for that

Reply

You must log in to post.

About this Plugin

About this Topic