• Resolved gseibold

    (@gseibold)


    Is it possible to add a WordPress function to the filename? I would like to have the users id in the filename i.e. filename_777.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Pablo Pacheco

    (@karzin)

    I’m going to add this to readme as I think it can help other users. It’s easy.

    First you have to create a custom rule in the filename structure option using curly braces, like {my_custom_rule}. You just have to write it, in any position you want

    Now you can use the filter frou_sanitize_file_name to create a custom function. In your case, as you want to put the user id it would be something like this:

    add_filter( 'frou_sanitize_file_name', function($filename_infs){
    	$filename_infs['structure']['translation']['my_custom_rule'] = get_current_user_id();
    	return $filename_infs;
    }, 20 );
    Thread Starter gseibold

    (@gseibold)

    Thank you for this. I will try it. Will I have to redo it each time you update the plugin?

    Plugin Author Pablo Pacheco

    (@karzin)

    You’re welcome. 🙂
    No, you don’t need to redo. Your rule will be there on next update.

    Thread Starter gseibold

    (@gseibold)

    Where do I put the “add_filter…” so that it doesn’t get written over?

    Plugin Author Pablo Pacheco

    (@karzin)

    You can put that in your functions.php for example

    Plugin Author Pablo Pacheco

    (@karzin)

    Hello @gseibold,
    I will close this ticket. If you have any troubles please just say it

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add WordPress function content to filename’ is closed to new replies.