• Resolved aburgin

    (@aburgin)


    Hello kind and noble helpers! This is my first post to the forum, so my apologies if my method of sharing code is frowned upon. But I wanted to be thorough in the info I offered for your guidance.

    I am currently working on a wp site that has an open-source tracking script (see below) incorporated into it. I have modified the script to include a mileage tracking system, which is in the “milog.php” file. (File link is below.) I included this in the wp-admin/user-edit.php file. I put all the tracking files in the wp-admin folder. Here is the site where I found the tracking script:

    http://scripts.kunals.com/script/affiliate-referral

    For the database, I created a backup of the wp_users db and appended the necessary tracking fields. I did not edit WP to use this new database but it is used in the tracking system seen in the user profile. (When this is working I will rename it so that WP will use the new one.) I am at the point where I want to use the wp login script but need to include the vital scripts from the other login. I am having a hard time locating the area in which I would integrate this into the wp-login file. I just need the tracker to know when a user logs in through WP.

    The link below leads to a zip file that has all the files in my wp-admin folder. There is also a file for the database called “wp_users_bu.sql”. Note the following folder structure followed by the .php files; everything else is in the root of wp-admin:

    act: login, logout, register
    usr: auth, home (inside usr) referral: calc, invite, points, profile, stats, tree

    https://docs.google.com/open?id=0B4T2mI0KPYniMDZkclVtUWNEbGc

    Since the tracking code is open source I plan on posting this for anyone who might want to make a free plugin for it. If this is not the proper place to ask for this kind of help please let me of the best site. Thank you in advance for your time and help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi!
    Are you absolutely set on that particular script? I found a free affiliate plugin and a couple of premium ones but I never actually tested them:

    1. http://ww.wp.xz.cn/extend/plugins/affiliates/ (Repository)
    2. http://premium.wpmudev.org/project/wordpress-mu-affiliate (Premium)
    3. http://www.tipsandtricks-hq.com/wordpress-affiliate-platform-plugin-simple-affiliate-program-for-wordpress-blogsite-1474 (Premium)

    Disclaimer: I have nothing to do with those plugins nor do am I an affiliate for any of them.
    Cheers!

    Thread Starter aburgin

    (@aburgin)

    Well, aside from the time and effort I put into this one (and a client who is eager to have a basic working site by the end of June) it wouldn’t break my heart to go with something different as long as I can work in all the features that are needed. I was drawn to that one because I understood most of the script and it was simple enough for me to edit it. (I’m still learning as much as I can about editing/integrating WP.)

    If it helps, a breakdown of what he wants is: the ability for a user to track miles that s/he has walked and have that data display in a “control panel”; a reference system where a user can invite others either via a link, code or email; a way for the user to see others who joined based on his/her link (or code or email); an area where users can see upcoming events sponsored by the organization.

    There are a few more but I think I can handle those; these are the areas I am having trouble with right now. If you have any other insights or suggestions I would be so happy to hear them. I will take a look at your list after responding and see how comfortable I feel working with any of them. Thank you so very much for your help!

    Moderator bcworkz

    (@bcworkz)

    I didn’t look at your files, so I may be off base, but sounds like you will want to hook the ‘wp_login’ action to run whatever functions you need to setup your scripts when a WP user logs in.

    Now that I have more information on what you are trying to accomplish, I’m not quite sure the plugins I suggested would work. I thought you needed the same functionality than an affiliate link, but it’s slightly more complicated than that.
    I had also suggested plugins because your approach involves editing WP core files, which is not recommended at all since edits will get overwritten when WP is updated. This opens the door for your client messing up things badly.
    I agree with bcworkz feedback, and I would also insert the custom DB info you need to make this work inside the WP DB, in a separate table.

    Thread Starter aburgin

    (@aburgin)

    Thank you both! Pulling the WP login is actually the problem I am having, I believe. I want to take the part of the login in the tracking system and put it into the wp_login script. But I’m not exactly sure where (and which parts) should be included in wp_login.

    Originally I had the custom info in a separate database, and I thought I had to have these in the wp-users table in order to make the two play nice. So, to clarify, I will still use the wp table to pull usernames/passwords, but keep all the updated tracking data in the custom db…is that right? Should I include a function that copies/writes the WP login ID to the custom db? That is the simplest way I can think of to have the tracking info stay connected to the right user when a new account is created.

    Right now when a user logs in he is directed to the standard wp profile page. Would it be better to create a separate “dashboard” page that calls the data from the wp-login? This way I would not be editing a core file but can still display the tracking info.

    I really appreciate your patience and help with my weak skills in this area. It is my first time working with databases this way and I’m having a hard time deciding the best way to make them work.

    After rereading your messages over and over again, I’m increasingly more convinced that the best approach for your problem would be to turn that tracking script into an actual WP plugin.
    As for the interaction between the script and the users table, you could add additional fields in Users profiles (and store them as metadata), which would later be retrieved by the plugin to do its magic.
    There are several plugins that can do this, such as the Extra User Details plugin. You could either use it as is or get some ideas from it about how to generate those extra fields.
    Another thing to take into account is that you would have to create the user interaction functionality and include it in the plugin since the WP User structure does not allow for that kind of functionality by default (AFAIK).
    That’s pretty much evth that I’ve got.
    Hope this helps.

    Thread Starter aburgin

    (@aburgin)

    Ooooo the Extra User plugin looks really good and may be just what I need. I’ll do some research on the process for making a plugin, but I may end up using this.

    I think once I can get a structure to put the tracking script into, I’ll be able to make the two work. Your advice has really helped me determine the best course to take for this project.

    One last question, then I’m done for now. If I need help creating a plugin out of the tracking script, is this the best place to ask about that?

    If I need help creating a plugin out of the tracking script, is this the best place to ask about that?

    Yeah, absolutely. You can also check out the Codex: there are many articles related to plugin development there. Also, there is a great NetTuts Tutorial about how to create a settings page in WP. Even though this particular tut is about theme options, most of the code is still relevant for plugins.
    Good luck!

    Thread Starter aburgin

    (@aburgin)

    Thank you for everything! I’ll mark this as resolved and start a new one when I need it.

    Marventus

    (@marventus)

    No problem. Good luck with your plugin.
    Do stop by again if you encounter any more problems.
    Cheers!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Integrating a current login script with wp-login script’ is closed to new replies.