Support » Plugin: BuddyPress XProfile Custom Image Field » registration upload picture make fake path and not displayed on profil user

  • Resolved fdlprod

    (@fdlprod)


    Hello,

    i tried to add a picture on a registration form, then i testes it…

    i have BP registration user plugin permit to validate a user but to see his data on a profile page..

    data are displayed but not the picture : https://www.iefsante.eu/wp-contentC:fakepath509.jpg this is the path of the picture, then if with my admin user i change with another picture on the profile it is working.

    any idea ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter fdlprod

    (@fdlprod)

    to make simple i use preactivation user and in bp_xprofile_data table intead of /profil/id and picture it create the picture path is c:fakepath”filename”.jpg

    Thread Starter fdlprod

    (@fdlprod)

    i am in your php file in method bpxp_image_field_save_on_signup

    $_FILES is null
    $_POST give me this

    [{\”id\”:\”signup_email\”,\”value\”:\”xxxx@gmail.comddvgg\”},{\”id\”:\”signup_password\”,\”value\”:\”ggg\”},{\”id\”:\”member_type\”,\”value\”:\”\”},{\”id\”:\”field_1\”,\”value\”:\”cyril leclerc\”},{\”id\”:\”field_40\”,\”value\”:\”C:\\\\fakepath\\\\pwact.jpg\”},{\”id\”:\”field_40_hidden\”,\”value\”:\”\”},{\”id\”:\”field_40_visibility\”,\”value\”:\”public\”},{\”id\”:\”custom_activation_mail\”,\”value\”:\”no\”},{\”id\”:\”bp_new_signup\”,\”value\”:\”7637091e44\”},{\”id\”:\”_wp_http_referer\”,\”value\”:\”/inscription-en-tant-quetudiant/\”}]

    so when i try to do $POST[‘field_40’] it is null

    it does’nt not work at all and i really need it i spend a really lot of time on it !

    Plugin Author Alex Githatu

    (@kalengi)

    Hello fdlprod

    Thanks for installing my plugin and sorry for the difficulties. I have some questions:

    1. What plugins have you installed?
    2. What steps/process are you using to register a user?
    3. What code customizations have you done for the registration process?

    Thanks…

    Alex

    Thread Starter fdlprod

    (@fdlprod)

    Hello,

    the form is here :
    https://www.iefsante.eu/inscription-en-tant-quetudiant/

    1.i only add your plugin and add in form base in buddypress 1 picture field
    but it come with wplms (buddy press, WPLMS plugins, membership, bbpress etc…)

    2.steps are click on link above fill form and click register !

    3. no code customization

    what i see is in the form page there is no fields_id hidden field it is really strange if you want i can give my email to get my credentials you can see directly on the server. it is really annoying because we must have the picture to validate a user… to validate it is a medecine user

    thanks

    Plugin Author Alex Githatu

    (@kalengi)

    Hello fdlprod

    I found the issue and applied a fix. You’ll be able to view the url of the posted image. BuddyPress does not allow display of images on the Manage Signups screen so you’ll have to copy the image url and post it into another browser tab to view.

    Replace the function bpxp_image_field_save_on_signup with the following code:

    function bpxp_image_field_save_on_signup($user_id, $user_login, $user_password, $user_email, $usermeta){
                global $bp;
                global $wpdb;
                 
                $update_signup_meta = false;
                $bp->bpxp_image_field = new stdClass(); 
                $bp->bpxp_image_field->user_id = $user_id;
                $posted_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
                
                $this->bpxp_image_field_save($posted_field_ids);
                
                
                foreach ( (array)$posted_field_ids as $field_id ) {
                    $field_name = 'field_' . $field_id;
    
                    if ( isset( $_FILES[$field_name] ) ) {
                        if ( empty( $_POST[$field_name] ) ) {
                            $file_name = $_FILES[$field_name]['name'];
                            $error_message = sprintf( __( 'The image %1$s was not uploaded.', 'bp-xprofile-image-field' ), $file_name );
                            bp_core_add_message( $error_message, 'error' );
                        }
                        else {
                            $image_path = $_POST[$field_name];
                            xprofile_set_field_data( $field_id, $user_id, $image_path );
                            
                            $image_url = WP_CONTENT_URL . $image_path;
                            $usermeta[$field_name] = $image_url;
    
                            $update_signup_meta = true;
                        }
                    }
                }
                
                if ($update_signup_meta) {
                    $query = $wpdb->prepare( "UPDATE {$wpdb->prefix}signups SET meta = %s WHERE user_login = %s", maybe_serialize($usermeta), $user_login );
                    
                    if ( ! $wpdb->query( $query ) ) {
                        return new WP_Error( 'signup_error', __( 'The image name could not be saved to the sign-up data', 'bp-xprofile-image-field' ) );
                    }
                }
    
                do_action( 'bpxp_image_field_save_on_signup', $user_id, $user_login, $user_password, $user_email, $usermeta );
            }

    Thanks…

    Alex

    Thread Starter fdlprod

    (@fdlprod)

    Hello,

    your really a great guy !

    awaiting this test i deactivated it and installed the xprofile custom fields which permit to use several different files and pictures…

    what is really complex is with the theme custom registration is not working at all !

    on a normal buddypress registration file still empty !

    i will try soon thank you !

    Plugin Author Alex Githatu

    (@kalengi)

    You’re most welcome 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘registration upload picture make fake path and not displayed on profil user’ is closed to new replies.