We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    I’m facing the following situation and hoping that folks here can help me wrap my head around this the right way...

    I have an external MySQL database containing info on club members. And a website that currently does not have any member login capability. I would like to figure out a way to efficiently setup usernames and passwords for these members which will allow them to log in and edit the data in this database.

    I have already setup WebLoginPE (v 1.3.1, with a modified templates.php file to allow profiling saving to work) as a test and can see that this seems to be what I want to use.

    My question for those experienced in whatever WebLoginPE does to tables, placeholders, variables, etc. is this : can I either import this external table into the MODx database and get the snippet to work with it (and if so, how) or are there parameters I can pass to the snippet to allow it work with this data?

    Essentially, I trying to find a shortcut way of creating a couple of hundred users with custom fields that they’ll be able to edit. Since all the data is already available, I’d like to think that some clever importing and form field definitions can make this task easier than doing it manually.

    In going through the docs it would seem that the custom table and custom fields parameters would be of help here. But I’m leery of stomping on data or somehow getting a table un-synced with variable/column/field definitions. In short, I’m trying to figure out what unknowns I don’t know about smiley

    Any advice?
    MattC
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes, you can tell WebLoginPE to use a custom table and what custom fields will be in it. It will create placeholders for the field values just as it will for its own tables. All you will need to do is customize the profile editing form and the profile display template.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 18913
        • 654 Posts
        Hi,
        Thanks for your reply. Do I need to import that external database (table) into the MODx database in order for WebLoginPE to be happy? Or can it stay an external db? A bit of doc that I read seemed to suggest that it could be a custom table, but not an external custom table.

        For the sake of discussion, assume I had an external table with these fields :
        &customTable=`web_user_custom_table` &customFields=`website,aim,msn,city,address`


        I read that this table will have the same structure as web_user_attributes_extended. Which I take to mean that it either will (if created by the snippet) or should (if created beforehand) have the additional fields of id, internalKey, first_name and last_name.

        How does that data get synced up to a given user? Put differently : Is there a "batch" way of creating a number of users by importing relevant fields into one or more MODx tables? Or are a couple of hundred users still going to be needed to be set up manually?

        Thanks for your patience!
        Matt
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It needs to be in the same database and also have the same table prefix as the rest of your MODx database. The web_user_attributes_extended table will be created with the fields you specify in the snippet parameters (if you don’t specify a custom table as well).
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            The web_users table holds the user’s ID, login name and an MD5 hash of the password. The rest of the default profile fields are in the web_users_attributes table with the internalKey field being the user’s ID (from the web_users table). Likewise the extended table uses an internalKey field to hold the user’s ID.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 18913
              • 654 Posts
              So if I want to import a user registration, then I would need to have entries inserted in the web_users and web_user_attributes tables, in addition to either the "extended" table or a specified custom table.

              Do you know if a web user being set up leaves "footprints" elsewhere that I would need to deal with? Or is there another safer way of doing a user set up (other than having them do it themselves)?

              Thanks again...
              MattC
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                As far as I have been able to determine the only thing the web_users_attributes table really needs to have is the email. Without that the Manager doesn’t display the user in its list of web users.

                Unless you are also adding an image for the user those three tables are all that would be effected.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 18913
                  • 654 Posts
                  Thanks. Before messing up a legit install, I’m trying to get the SQL syntax correct for importing data into the three tables. The only thing I can’t figure out is how to insert a temporary password into the password field of web_users. It looks like it wants to be stored as the MD5 hash, but I can’t figure out how to have that conversion done in SQL (the field is being read in from a CSV file and it holds the "real" temporary password, e.g. "temppwd807")

                  If anyone reading this has thoughts on that, I’d like to hear it. Otherwise, it’s off to flipping through more SQL docs...
                  MattC
                    • 18913
                    • 654 Posts
                    As usual, the solution appears shortly after I hit "send." Dunno why this
                    UPDATE modx_web_users SET password = MD5( password )

                    didn’t work before but there was most certainly a reason. Now we’ll see if this works in practice ...
                    MattC
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      the password is a string, so it has to be in quotes
                      password=MD5('password') 
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org