Please upgrade here. These earlier versions are no longer being updated and have security issues.

Forcing User Profile Image

Hello,

I'd like to disable all of my forum users ability to change their picture and also set it to a forced image URL, for example site.com/{username}.png, how could I go about doing this?

Thank you.

Comments

  • peregrineperegrine MVP
    edited August 2014

    will prevent editing/changing of profile pics, once you set it.

    $Configuration['Garden']['Profile']['EditPhotos'] = FALSE;

    Unfortunately this prevents Admins from changing pics as well after it is set.

    if the core had this then admins could add and edit all user pics, but user couldn't add or edit.

       public function Picture($UserReference = '', $Username = '', $UserID = '') {
         $IsAdmin = Gdn::Session()->CheckPermission('Garden.Users.Edit');
    
         if ((!$IsAdmin) || (!C('Garden.Profile.EditPhotos', TRUE))) {
             throw ForbiddenException('@Editing user photos has been disabled.');
          }
    

    instead of this

    https://github.com/vanilla/vanilla/blob/2.1/applications/dashboard/controllers/class.profilecontroller.php#L615

    as far as naming - you would need to make more mods in core, or just manually change image filenames and usertable references.

    not quite sure why the name of the user's photo is critical, you might want to explain.

    If a user joins the name will be unique, and unless you are a mind-reader the photo won't be there anyways.

    Unless you create something a home grown vanillicon and base it off of usernames.

    or maybe you are looking for something like default avatar.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited August 2014

    btw

    @vrijvlinder created this unique set of animatars, they may be available for purchase.

    I believe its from the "altered state collection". great for post-hypnotic suggestions.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    vrijvlinderUnderDog
  • peregrineperegrine MVP
    edited August 2014

    a quick kluge.

    it may work for you, however I am not supporting code.

    <?php if (!defined('APPLICATION')) exit();

    // Define the plugin:
    $PluginInfo['CustomAvatar'] = array(
       'Name' => 'CustomAvatar',
       'Description' => "Provides a custom user avatar from image   username.png   plugins/CustomAvatar folder.  You need to create the username.png for each user name ",
       'Version' => '1.0',
       'Author' => 'Peregrine',
       'MobileFriendly' => TRUE,
    );
    
    class CustomAvatarPlugin extends Gdn_Plugin {
       public function ProfileController_AfterAddSideMenu_Handler($Sender, $Args) {
           $Sender->User->Photo =  Asset(C('Plugins.CustomAvatar.Image', 'plugins/CustomAvatar/' . $Sender->User->Name . '.png'), TRUE);        
       }
    }
    
    if (!function_exists('UserPhotoDefaultUrl')) {
       function UserPhotoDefaultUrl($User, $Options = array()) {
         $UserName = GetValue('Name', $User);
         $PhotoUrl =  Asset(C('Plugins.CustomAvatar.Image', 'plugins/CustomAvatar/' . $UserName . '.png'), TRUE);
         return $PhotoUrl;
       }
    }
    

    put all username photos in the plugins/CustomAvatar avatar folder.
    and set the photo field in the user table to either to blank and it will read the photo from the folder as UserDefaultUrl

    e.g.

    plugins/CustomAvatar/DansTooGood.png

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDogBleistivt
  • Thank you :)

    I'm having an issue now that the "New Discussion" button is showing to guests. Any idea where I could change this?

  • peregrineperegrine MVP
    edited August 2014

    that would be a new discussion topic I think.

    so did the plugin work for you?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • @peregrine‌ I downloaded a temporary addon that seemed to work.

    If I experience problems or need more customization I'll be sure to use your plugin.

Sign In or Register to comment.