Profile Picture mandatory

georg yurij Posted in Technical Support 3 years ago

Is there a way to make profile picture upload as mandatory (requiered field) when editing Profile?

Replies
Indonesian Arsalan Shah Replied 3 years ago

No the user is registered and the hook is used inside the component to execute once its added. If you getting same error can you share your website URL just for us to take a look into the XHR request whether it is actually sending picture or not.

German Georg yurij Replied 3 years ago

Yes Image upload is working without problems after login, maybe the error is because there is no profile existing while registration.

Indonesian Arsalan Shah Replied 3 years ago

Do you able to upload images in wall post after login? if so its not the hosting provider. If can't upload wall post photo also then ask your hosting provider to enable PHP GD extension for your account.

German Georg yurij Replied 3 years ago

What engine u are using to check the uploadet file? Maybe my hosting provider is not supporting that.

German Georg yurij Replied 3 years ago

I´m using OSSN premium 6.1

It also works not without Anonymous Registration, i´ll try with some more disabled components

Indonesian Arsalan Shah Replied 3 years ago

It works fine for me with Anonymous user registration you need to make sure you are using OSSN 6.x I guess you are using OSSN 5.6 ?

German Georg yurij Replied 3 years ago

If 6kB are small, yes.

Indonesian Arsalan Shah Replied 3 years ago

Did you tried to upload very small file to see if it is not size issue?

German Georg yurij Replied 3 years ago

The component you created is working great together with anonymous registration component, but it cant regognize the jpg file i try to upload:
enter image description here

Indonesian Arsalan Shah Replied 3 years ago

Sorry I missed that part. I actually published such a component that I talked https://www.opensource-socialnetwork.org/component/view/5484/signup-profile-picture

In your case it requires you may use following code that

  1. Add hooks for actions and check if action is group/join
  2. In hook if action is group/join make user have required stuff other wise throw error.

As the hooks run before action happened so it won't send request for join. You an add following in your component file.

I HAVE VERIFIED IT BUT YOU CAN HAVE A BASIC UNDERSTANDING YOU MAY ADJUST CONDTIONS BELOW

function group_join_notice_init(){
        ossn_register_callback('action', 'load', 'group_join_user_validate');
}
function group_join_user_validate($callback, $type, $params){
        if(isset($params['action']) && $params['action'] == 'group/join'){
                $user = ossn_loggedin_user();
                if($user){
                        if( !isset($user->icon_guid) || (isset($user->icon_guid) && empty($user->icon_guid)) || !isset($user->category) || (isset($user->category) && empty($user->category)) ){
                                ossn_trigger_message("You need to add your profile photo and select a user category on profile edit page before joining the group!", "error");
                                redirect(REF);
                        }
                }
        }
}
ossn_register_callback('ossn', 'init', 'group_join_notice_init');