We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15076
    • 43 Posts
    Hi all,

    I would like to be able to give the administrators the possibility to approve a user. So the user registers by supplying his email address and full name (if he wants), the username will be his email address. Then there should go an email to an administrator that the user wants to be approved. If the administrator approves, the user gets an email with a password, which he can change when he is logged in.

    I searched my way around webloginpe, and found out it has the functionality to let a user register, and then send him an email with password to make sure the email is allright. It doesn’t give any admin approval though:(

    Searching the internet showed me the webloginpe google project, where this is a feature request since october 2008. Since it is not implemented yet, I don’t think there will be an implementation soon.

    Therefor I want to try to achieve this myself. I was thinking to create a plugin that invokes on the event OnWebSaveUser. This plugin will put an extra value in the db, named validated, and puts it to false, it will also block the user. It will notify the administrator, and disables the further process.

    The administrator gets an email and will login to the manager to use a module to approve the user. The module will put the validated to true and blocked to false. It wil generate a password for the user and sends it to the user.

    You are the guys that know all about webloginpe, is this doable? For myself the hardest point is to disable the process of registering by a plugin. Any thoughts on this part?

    Thanks in advance,

      • 1892
      • 82 Posts
      Although it’s not fully documented yet there is a ’verify’ option within WebloginPE which allows you to manually approve users, this verification process can be sent to the admin team if required.

      Before creating a new plugin have a look through this thread
      on manually approving new users. This may provide the solution you need.


        • 15076
        • 43 Posts
        Adrian, thanks for posting the link to the thread. It is indeed exactly what I needed.

        I tried to set webloginpe as posted in the thread, and now the administrator gets an email that there is a user needing validation. I am stuck at the part of creating a page to give administrators the ability to approve the users.

        I created a new page for it, with the following call:
        [!WebLoginPE? &type=`manager` &activateId=`40` !]

        When I load the page, I get the following error:
         Error: 	Invalid argument supplied for foreach()	 
          Error type/ Nr.: 	Warning - 2	 
          File: 	C:\wamp\www\assets\snippets\webloginpeN\webloginpe.class.php	 
          Line: 	1395	 
          Line 1395 source: 	foreach($attributes as $field => $value)  

        I debugged a bit by using print statements, and it turned out that the $attributes value is empty. Anyone has any idea how I can solve this?
          • 1892
          • 82 Posts

          Glad it’s helped to some degree! To get it working is the next stage. First I must say I’m still learning the ropes on modx so my suggestions might not be advice, I’ll I can say is what I’ve found to work.

          Lets go through a check list

          1. Have you created a web users group called ’Pending Users’? When someone registers then pending users get added to this group, you should be able to go into the manager and see if new applicants get added to the group. If this doesn’t work then the rest of the process falls over.

          2. On your activate new members chunk do you have something along the lines of
          <input type="hidden" name="usergroup" value="club member" />
          , again the defined value "club member" needs to be a web user group that you’ve already defined. When you approve the new applicant they will get moved from the "Pending Users" group to the "club member" group. You can change these names if you want to but they do need to be defined web user groups.

          3. Finally I think the call for approval of new members needs to have an extra couple of fields.
          [!WebLoginPE? &type=`manager` &activateId=`40` &groupsField=`usergroup` &usersList=`The following accounts require approval:default:approveNewUser:username:ASC:webgroup(Pending Users)`!]

          The value of the groupsField parameter needs to match the hidden field name in step 2 above, and the usersList parameter is filtering for all members in the webgroup ’Pending Users’). Hopefully one of these last two parameters will supply the necessary attributes value. I suspect it’s the groupsField link to the hidden input field in step 2. I believe you can define multiple groups in the value, in which case the for each loop in your code error is the looping around each group listed.

          I hope this helps.

            • 15076
            • 43 Posts
            thanks for your help.

            I think the problem is in checklist #2, as I don’t have any chunk for my approve page. I copied your call of step 3 and still got the same error and I do have a user group pending users, where the users that newly register also get in.

            Could you please post an example of your chunk?

            Thanks in advance
              • 1841
              • 141 Posts
              Did anyone manage to solve this issue as I have the same problem.
                • 1841
                • 141 Posts
                I am still having the same issues has anyone managed to solve this problem?
                  • 50752
                  • 1 Posts
                  It's an old topic but still - for those like me who is looking for the answer.

                  I had this

                  MODX Parse Error »
                  Error : Invalid argument supplied for foreach()
                  File /home/anastasia/web/amires/www/assets/snippets/webloginpe/webloginpe.class.php
                  Line 1373
                  Source foreach($attributes as $field => $value)

                  on a page with the snippet call
                  [!WebLoginPE? &type=`manager` &groupsField=`usergroup` &activateId=`45` &usersList=`The following accounts require approval:default:approveNewUser:username:ASC:webgroup(Pending Users)`!]

                  This forum's a lifesaver for me (in Russian): http://community.modx-cms.ru/blog/solutions/2811.html

                  The thing is that the number of entries in these modx database tables should be same:

                  I had previous (before webloginpe install) entry in 'web_users' so there was +1 entry in there. I deleted it, now problem fixed.