Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Forced profile update

Like the title says: is there a way to force registered users to (one time) update their profile ? Vanilla 2.1.

Comments

  • Options

    to do what?

    grep is your friend.

  • Options

    I've installed the extend profile fields plugin and made some fields mandatory upon registration, I'd like existing users to update these fields aswell.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    Put a message up asking users to do it?

    Or do you want to remove their permissions until they do it?

    How many users are we talking about?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    I would just redirect to the edit profile page on signin - untested, as I'm not at home:

    Base_AfterSignIn_Handler($Sender) {
        $Session = Gdn::Session();
        $Meta = Gdn::UserMetaModel()->GetUserMeta($Session->UserID, 'Profile.YourField');
        if ($Meta['Profile.YourField'])
            return;
        $Session->Stash('SetProfileField', true);
        Redirect('profile/edit');
    }
    
    ProfileController_Render_Before($Sender) {
        if (Gdn::Session()->Stash('SetProfileField'))
            $Sender->InformMessage('Please edit YourField.');
    }
    
  • Options

    Thanks a lot ! I will try that. @hgtonight, I have about 1100 users. To get the idea: http://audi-a2.nl/discussion/3166/hallo-mijn-beste-a2-vrienden#latest I want the users to complete their profile because the added info shows up right after the profile-links. See link above.

  • Options

    @bleistivt I put that code into a plugin and it works more or less. Problem is in the Bootstrap theme I think. I get a sort of overlay with the settings after login. Is it possible to open the redirect in a new tab ? I experimented a bit with javascript but couldn't get it to work.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Instead of Redirect('profile/edit'); you can try echo '<script>window.open("', Url('/profile/edit'), '","_blank")</script>';

  • Options

    Add this after line 6 in what I posted:

    $this->AddDefinition('CheckPopup', true);
    
  • Options
    BleistivtBleistivt Moderator
    edited October 2014

    or... scratch that and replace line 7 with this

    $Sender->Target('profile/edit');
    

    I can't test this right now but will later if it doesn't work.

  • Options

    Thanks all, did some testing:

    $Sender->Target('profile/edit');

    The "UserModel" object does not have a "xTarget" method.|UserModel|xTarget|

    $this->AddDefinition('CheckPopup', true);

    The "RedirectProfilePlugin" object does not have a "xAddDefinition" method.|RedirectProfilePlugin|xAddDefinition

    The javascript solution produces no output nor does it redirect

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @piotrnl said:
    The javascript solution produces no output nor does it redirect

    Is there any error message in the console?

    Or is the html source of the "no output" simply the script tag? If that is the case try this: echo '<html><head></head><body onload="window.open(\'', Url('/profile/edit'), '\',\'_blank\');"</body></html>';

    Not sure if I escaped everything right, though... If it does not work, please post the source of the blank page

  • Options

    it better to use a redirect becuase you can't guarantee you will be able to open a new tab or window. That is the sort of thing that can be blocked by a browser settings especially automated.

    grep is your friend.

  • Options

    InformMessage is a good solution, if it not displaying properly this is a cosmetic problem.

    grep is your friend.

  • Options

    Another solution would be to use on of the view hooks to display and info box

    grep is your friend.

  • Options
    <?php if (!defined('APPLICATION')) exit();
    
    $PluginInfo['RedirectProfile'] = array(
        'Name' => 'RedirectProfile',
        'Description' => '',
        'Version' => '1',
        'Author' => 'Bleistivt',
    );
    
    class RedirectProfilePlugin extends Gdn_Plugin {
    
        public function Base_AfterSignIn_Handler($Sender) {
            $Session = Gdn::Session();
            $Meta = Gdn::UserMetaModel()->GetUserMeta($Session->UserID, 'Profile.YourField');
            if ($Meta['Profile.YourField'])
                return;
            $Session->Stash('SetProfileField', true);
            Gdn::Controller()->Form->SetFormValue('Target', Url('profile/edit'));
        }
    
        public function ProfileController_Render_Before($Sender) {
            if (Gdn::Session()->Stash('SetProfileField'))
                $Sender->InformMessage('Please edit YourField.');
        }
    
    }
    
Sign In or Register to comment.