Ok, the issue is the file path then. The path of a file is based off the owner. You'll need a more advanced auto action to modify the object by reference so the path generates properly. Below should work.
Global
Triggers: gallery_onBeforeCreateGalleryItem
Type: Code
User: User
Access: Everybody
Conditions
1: [var3_asset] Is REGEXP /^profile\.\d+/
Action
Method: PHP
Code:
Code:
$variables['var3']->set( 'user_id', '[user_id]' );
Parameters
Reference Variables: Variable 3
Note for the above to work please ensure CB Gallery is up to date.
This is technically a bug in CB Gallery though. Uploads should always be from the user making the upload instead of the user owning the gallery. Have added a bug ticket to investigate and fix in a later release.
forge.joomlapolis.com/issues/6799