Plugin Author
donmik
(@atallos)
Hi,
I believe right now you cannot change the upload dir without changing my plugin. Maybe using ‘upload_dir’ filter you can do it, but it will be easier if I provide a new filter specific for my plugin. I will do it on next release, hope to ship it this monday.
About your second question, you can do it using “bp_xprofile_field_edit_html_elements”:
add_filter( 'bp_xprofile_field_edit_html_elements', 'accept_only_images', 10, 2 );
function my_custom_html_elements($r, $field_class) {
if ($field_class === 'Bxcft_Field_Type_Image') {
$r['accept'] = 'image/*';
}
return $r;
}
Hey,
Thanks for the reply.
I’ll try the solution to your second question and will wait for the new filter.
I’m keeping this topic open till the time. Will mark resolve after the update!
Thanks a lot!
Hey,
I tried the filter by inserting the code to theme’s functions.php
I’m getting an error. Please assist me with the problem.
Thanks in advance.
Plugin Author
donmik
(@atallos)
What error are you getting?
Plugin Author
donmik
(@atallos)
Ok, I’m dumb…xD. I changed the name of the function and forget to change the name inside the add_filter call… Sorry.
add_filter( 'bp_xprofile_field_edit_html_elements', 'accept_only_images', 10, 2 );
function accept_only_images($r, $field_class) {
if ($field_class === 'Bxcft_Field_Type_Image') {
$r['accept'] = 'image/*';
}
return $r;
}
Lol. No problem XD
and Thanks. It’s working now! (Y)
I’m waiting for the update so that I can mark this topic as resolved.
Thanks once again.
Hey,
Thank you for the update and the new filter.
Please assist me with the code. How can I use ‘bxcft_upload_dir’?
Plugin Author
donmik
(@atallos)
The default upload dir is: “wp-content/uploads/profiles/USERID/”
add_filter( 'bxcft_upload_dir', 'my_upload_dir', 10, 2);
function my_upload_dir($path, $user_id) {
return str_replace('profiles/', 'custom_dir/', $path);
}
This code will replace the “profiles” folder with a folder named “custom_dir”.
Hey.
Thanks. It’s working!
I tried couple of modification to the code so that I can have this: “MY_UPLOAD_DIR/registration/year/month/day/USERNAME/”
add_filter( 'bxcft_upload_dir', 'my_upload_dir', 10, 2);
function my_upload_dir($path, $year, $month, $day, $display_name) {
return str_replace('profiles/', 'registration/', $path);
}
And umm, it’s not working. Any solution?
Sorry for so many questions.. but I can’t get it.
Thanks
Plugin Author
donmik
(@atallos)
You cannot change the parameters of the filter. The following code should work.
add_filter( 'bxcft_upload_dir', 'my_upload_dir', 10, 2);
function my_upload_dir($path, $user_id) {
return '/registration/' . date('Y/m/d') . '/' . bp_core_get_user_displayname($user_id);
}
This will save your files inside:
“wp-content/uploads/registration/2016/04/30/USERNAME/”
Hey!
Thank you soooo much..
It’s working. Finally! 😀