Forum Replies Created

Viewing 15 replies - 466 through 480 (of 574 total)
  • Plugin Author tbenyon

    (@tbenyon)

    I so badly wish I could sit at your machine with you to help you faster 😛

    My new theory is that because you are getting JSON data stored, in that field, and it’s not getting stored in the database that there must be some sort of validation that is blocking this within WordPress. This is the bit that WordPress handles by default and I haven’t changed a lot. I don’t know why I’m not experiencing this (I’m going to try a fresh WP build this evening when I have more time).

    Next steps:

    1. Can you double check you’re looking in the DIV tag with the classes “option-container repeater exlog-repeater-master”
    2. In there find the INPUT with the class “exlog_repeater_data_store”
    3. In the inspector, change its TYPE attribute from “hidden” to “text”
    4. You should see the red input field appear
    5. Delete what is currently in there and just write “FUNKY MONKEY”
    6. Save the form
    7. Check your database to see if “FUNKY MONKEY” has appeared in there

    If it has, we can start to guess that maybe it’s do with:

    • The input being hidden
    • The JSON data you’re seeing appear in there not being accepted
    • Setting the value of this item is setting the attribute but not it’s real value?! Seems odd but I’m running out of ideas 😛

    Thanks for being so patient. I know this will help you but it’s also really appreciated by me to have such a supportive user as it means I can have a more stable plugin for other users. Thank you!

    • This reply was modified 7 years, 5 months ago by tbenyon.
    Plugin Author tbenyon

    (@tbenyon)

    So typing in field name values isn’t updating the data but typing in the field values does.

    That sounds like a bug in itself but I’ll come back to that because if the data is getting updated in that field, but when you press the save button you are not seeing it in the database that is the first issue to solve.

    Let’s do a couple more checks:
    In the wp_options table you can see the field “exlog_exclude_users_field_name_repeater” and in your case this has the “option_value” of “false”?

    Could you please:

    1. Delete the row entry for this field in the database
    2. Update one of the field values in the options area
    3. Check that the “exlog_repeater_data_source” value is updated with data
    4. Click save
    5. Check that the “exlog_exclude_users_field_name_repeater” has reappeared in your datbase options table
    6. Confirm with me the value of that field in the database

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Sorry – I made a wrong comment about step one, please do this instead:

    1) PHP error logs
    You are hitting the test button on site A and getting the 500 error. Can you please get me the PHP errors for the site you are hitting the test button on (site A) that occurred at the time you clicked the Test button.

    Plugin Author tbenyon

    (@tbenyon)

    Hey @piska,

    Apologies for the delayed response.

    The 500 should mean that you have got a connection to the server but it is returning an error.

    Two things we can do:

    1) PHP error logs
    You are hitting the test button on site A and getting the 500 error. Can you please get me the PHP errors for site B that occurred at the time you clicked the Test button.

    2) Get more information from the front end JS error

    If you’re able, can you replace all the code in this file (/wp-content/plugins/external-login/js/exlog_test.js) on site A.

    Could you please delete the previous code paste the following code in there instead.

    console.log("EXLOG - Test file loaded.");
    (function ($) {
        $(function () {
            console.log("EXLOG - Test file loaded jQuery.");
            var $modal = $(".exlog_modal");
            var $loader = $(".exlog_loader_container");
            var $modal_content_container = $(".exlog_test_results_inner_container", $modal);
            var $modal_test_results = $(".exlog_test_results", $modal);
            var $modal_error = $(".exlog_test_fail", $modal_content_container);
            var $modal_error_title = $(".exlog-error-title", $modal_error);
            var $modal_error_message = $(".exlog-error-message", $modal_error);
            var wordpressBaseUrl = $('[data-exlog-wp-base]').attr('data-exlog-wp-base');
    
            var error_messages = {
                unknown: {
                    title: "Error",
                    message: "This is an unknown error."
                },
                lost: {
                  title: "Error",
                  message: "Could not access the server to run the test."
                },
                server: {
                    title: "Error",
                    message: "There was an error on the server."
                },
                empty_result: {
                  title: "Error",
                  message: "No data returned from the server. Please check your settings."
                }
            };
    
            var error_codes = {
              100: error_messages.unknown,       // Ajax returned, unknown error
              101: error_messages.unknown,       // Unknown error passed to error handler
              404: error_messages.lost,          // 404 from Ajax
              500: error_messages.server,        // 500 from server - see test_results.php?
              501: error_messages.server,        // String of "0" returned - caused by missing function?
              502: error_messages.server,        // 500ish error from Ajax
              600: error_messages.empty_result,  // Empty AJAX response
              601: error_messages.empty_result   // Blank string AJAX response
    //        999: ????????????????????????      // Hard coded in markup case this system fails
            };
    
            function errorMessageState(error_code) {
              if (!error_code) {
                $modal_error.hide();
              }
    
              if (!error_codes.hasOwnProperty(error_code)) {
                error_code = 101;
              }
    
              var error_data = error_codes[error_code];
    
              $modal_error_title.text(error_data.title + ": " + error_code);
              $modal_error_message.text(error_data.message);
    
              $modal_error.show();
            }
    
            $(".exlog_close_button", $modal).click(function () {
                $modal_error.hide();
                $modal.hide();
                $modal_test_results.text("");
            });
    
            $("input.exlog_test_connection").click(function () {
                console.log("EXLOG - Test button clicked.");
                $modal.show();
                $loader.show();
                var data = {
                    'action': 'exlog_test_connection',
                    'test_results': 10
                };
    
                console.log("EXLOG - About to make request.");
                $.ajax({
                    type: "GET",
                    url: wordpressBaseUrl + "/wp-admin/admin-ajax.php",
                    data: data,
                    success: function (data) {
                        if (typeof data === 'string') {
                          data = data.trim();
                        }
    
                        if (!data) {
                          console.log("EXLOG - NO DATA");
                          errorMessageState(600);
                          $modal_error.show();
                        } else if (data == "") {
                          console.log("EXLOG - EMPTY STRING DATA");
                          errorMessageState(601);
                          $modal_error.show();
                        } else if (data === "0") {
                          errorMessageState(501);
                        } else {
                          console.log("EXLOG - SUCCESS!!! WHOOP!");
    
                          $modal_error.hide();
                          $modal_test_results.append(data);
                        }
                        $loader.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError){
                      console.log("EXLOG - Request fail!!!");
                      console.log("Status: ", xhr.status);
                      console.log("Response Text: ", xhr.responseText);
                      if(xhr.status == 404) {
                        errorMessageState(404);
                      } else if (xhr.status === 500) {
                        errorMessageState(500);
                      } else if (Math.floor(xhr.status / 100) === 5) {
                        errorMessageState(502);
                      } else {
                        errorMessageState(100);
                      }
                      $loader.hide();
                    }
                });
            });
        });
    }(jQuery));

    Can you then open the inspector and look at the browsers console.

    I’m interested particularly to see the output that follows “Response Text: “.

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hey @xprojectsx,

    I’m really sorry as I have got confused between two support tickets. Really embarrassed and sincere apologies.

    To update where we’re up to:

    • The repeater front end is working in that you can add values and the add items buttons work
    • When you click save the page refreshes, however the values get wiped out
    • After this when you look in the database at the “exlog_exclude_users_field_name_repeater” field you only have the value “false” stored
    • To even get this far you’ve had to modify the code in the plugin as discussed in a different support ticket here: https://wordpress.org/support/topic/fatal-error-3102/

    Assuming all this is correct let’s do some more checks.

    1) Is the data store updating in the JS
    I’m going to reference this image to help you find what you need to:
    https://ibb.co/2M6G4JD

    Screen-Shot-2019-01-16-at-8-19-40-AM

    Can you please

    1. Refresh the page
    2. Type something in to the exclude users boxes
    3. Inside exlog-repeater-master (red in pic) there is a hidden input with the class exlog_repeater_data_source (purple in pic) and that has a value attribute (blue in pic). Can you see any data in that?
    4. If you can see data, it should be updating everytime you type anything in to any input in the exclude users section. Is that the case?

    Again, I’m really embarrassed for my confusion – sincere apologies.

    Thanks for your patience,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    If that is all you are seeing in the console, even after clicking the test button, it must be that the error that follow are preventing Javascript to continue running.

    I’m going to ask you to do something that I hate it when people ask me to do but I think may be the cause of your problem. I’m starting to think this is nothing to do with my plugin but your theme or another plugin that is causing a JS error which is blocking other JS from running.

    The reason I think this is these two lines are very basic and they should execute when you click the test button:

    
            $("input.exlog_test_connection").click(function () {
                console.log("EXLOG - Test button clicked.");
    

    –To Try–
    Please set your theme back to the default 2019 theme and disable other plugins.
    Keep turning all this off until you find this is all working.

    If you disable all and reset your theme and find it works with just my plugin you can gradually include plugins again until you find the one that is causing the issue.

    I may be wrong bit it is strange that this simple code is not running.

    If this doesn’t work for you, we could start to find out why this JS isn’t running when you click the button.

    Sorry this is taking time. It’s hard to solve when I can’t replicate.

    I won’t give up on this 🙂

    Plugin Author tbenyon

    (@tbenyon)

    The last message I sent had three sections and I’ll go back through them below:
    1) Test that your error logs are working

    You’ve added error_log("-----------EXTERNAL LOGIN TESTING!!!!!------------"); to your functions.php and you can see this coming through. However, when you click the test button you are not getting any more error logs however you are still seeing the 500 error message.
    Let me know if this is not correct.

    2) Test if we’re getting to the test query function in the plugin
    I made a mistake here as I wrote the wrong file path.

    I meant this file:
    wp-content/plugins/external-login/login/db.php

    Could you try replacing code for the function I specified above and see what additional error logs you get.

    3) Get more information from the front end JS error
    If I’m not mistaken you tried swapping out the code with the example above and you saw no error logs.

    I’m going to ask that you replace all the code in this file (/wp-content/plugins/external-login/js/exlog_test.js)

    Could you please delete the previous code paste the following code in there instead. If you still don’t see any error logs you must be loading in the wrong file somehow.

    
    console.log("EXLOG - Test file loaded.");
    (function ($) {
        $(function () {
            console.log("EXLOG - Test file loaded jQuery.");
            var $modal = $(".exlog_modal");
            var $loader = $(".exlog_loader_container");
            var $modal_content_container = $(".exlog_test_results_inner_container", $modal);
            var $modal_test_results = $(".exlog_test_results", $modal);
            var $modal_error = $(".exlog_test_fail", $modal_content_container);
            var $modal_error_title = $(".exlog-error-title", $modal_error);
            var $modal_error_message = $(".exlog-error-message", $modal_error);
            var wordpressBaseUrl = $('[data-exlog-wp-base]').attr('data-exlog-wp-base');
    
            var error_messages = {
                unknown: {
                    title: "Error",
                    message: "This is an unknown error."
                },
                lost: {
                  title: "Error",
                  message: "Could not access the server to run the test."
                },
                server: {
                    title: "Error",
                    message: "There was an error on the server."
                },
                empty_result: {
                  title: "Error",
                  message: "No data returned from the server. Please check your settings."
                }
            };
    
            var error_codes = {
              100: error_messages.unknown,       // Ajax returned, unknown error
              101: error_messages.unknown,       // Unknown error passed to error handler
              404: error_messages.lost,          // 404 from Ajax
              500: error_messages.server,        // 500 from server - see test_results.php?
              501: error_messages.server,        // String of "0" returned - caused by missing function?
              502: error_messages.server,        // 500ish error from Ajax
              600: error_messages.empty_result,  // Empty AJAX response
              601: error_messages.empty_result   // Blank string AJAX response
    //        999: ????????????????????????      // Hard coded in markup case this system fails
            };
    
            function errorMessageState(error_code) {
              if (!error_code) {
                $modal_error.hide();
              }
    
              if (!error_codes.hasOwnProperty(error_code)) {
                error_code = 101;
              }
    
              var error_data = error_codes[error_code];
    
              $modal_error_title.text(error_data.title + ": " + error_code);
              $modal_error_message.text(error_data.message);
    
              $modal_error.show();
            }
    
            $(".exlog_close_button", $modal).click(function () {
                $modal_error.hide();
                $modal.hide();
                $modal_test_results.text("");
            });
    
            $("input.exlog_test_connection").click(function () {
                console.log("EXLOG - Test button clicked.");
                $modal.show();
                $loader.show();
                var data = {
                    'action': 'exlog_test_connection',
                    'test_results': 10
                };
    
                console.log("EXLOG - About to make request.");
                $.ajax({
                    type: "GET",
                    url: wordpressBaseUrl + "/wp-admin/admin-ajax.php",
                    data: data,
                    success: function (data) {
                        if (typeof data === 'string') {
                          data = data.trim();
                        }
    
                        if (!data) {
                          console.log("EXLOG - NO DATA");
                          errorMessageState(600);
                          $modal_error.show();
                        } else if (data == "") {
                          console.log("EXLOG - EMPTY STRING DATA");
                          errorMessageState(601);
                          $modal_error.show();
                        } else if (data === "0") {
                          errorMessageState(501);
                        } else {
                          console.log("EXLOG - SUCCESS!!! WHOOP!");
    
                          $modal_error.hide();
                          $modal_test_results.append(data);
                        }
                        $loader.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError){
                      console.log("EXLOG - Request fail!!!");
                      console.log("Status: ", xhr.status);
                      console.log("Response Text: ", xhr.responseText);
                      if(xhr.status == 404) {
                        errorMessageState(404);
                      } else if (xhr.status === 500) {
                        errorMessageState(500);
                      } else if (Math.floor(xhr.status / 100) === 5) {
                        errorMessageState(502);
                      } else {
                        errorMessageState(100);
                      }
                      $loader.hide();
                    }
                });
            });
        });
    }(jQuery));
    

    Thanks for your patience – I’m sure we’ll get there working together on this 🙂

    Tom

    • This reply was modified 7 years, 5 months ago by tbenyon.
    Plugin Author tbenyon

    (@tbenyon)

    I may be wrong but it sounds like your PHP errors aren’t coming through.

    The 500 error only appears if there is an error on the server.

    There’s a few more things to do so that we can the required error information.

    Test that your error logs are working
    In your functions.php file, at the very top add:
    error_log("-----------EXTERNAL LOGIN TESTING!!!!!------------");

    If when you refresh your page you are not seeing this in your error logs then we need to fix that first. Make sure you’re looking at the logs for the server where you are pressing the test button from.

    Test if we’re getting to the test query function in the plugin
    If we are seeing the above error log that’s great.

    Let’s see if we’re getting to the test function in the plugin.

    Let’s add this line of code:
    error_log("External Login - We're starting the test query!!!!!!!!!!!!");

    . . . to this file:
    wp-content/plugins/external-login/js/exlog_test.js

    . . .in this function:
    exlog_test_query()

    . . . so that it now looks like this:

    function exlog_test_query($limit = false) {
        error_log("External Login - We're starting the test query!!!!!!!!!!!!");
        $dbType = exlog_get_option('external_login_option_db_type');
        $db_data = exlog_get_external_db_instance_and_fields($dbType);
        if ($dbType == "postgresql") {
            $query_string =
                'SELECT *' .
                ' FROM "' . esc_sql($db_data["dbstructure_table"]) . '"';
            if ($limit && is_int($limit)) {
                $query_string .= ' LIMIT ' . $limit;
            }
            $rows = pg_query($query_string) or die('Query failed: ' . pg_last_error());
            $users = array();
            if (sizeof($rows) > 0) {
                while ($x = pg_fetch_array($rows, null, PGSQL_ASSOC)) {
                    array_push($users, $x); //Gets the first row
                };
                pg_close($db_data["db_instance"]);
                return $users;
            }
        } else {
            $query_string =
                'SELECT *' .
                ' FROM ' . esc_sql($db_data["dbstructure_table"]) . '';
            if ($limit && is_int($limit)) {
                $query_string .= ' LIMIT ' . $limit;
            }
            $rows = $db_data["db_instance"]->get_results($query_string, ARRAY_A);
            $users = array();
            if (sizeof($rows) > 0) {
                foreach ($rows as $user_data) {
                    array_push($users, exlog_build_wp_user_data($db_data, $user_data));
                };
                return $users;
            }
        }
        //If got this far, query failed
        error_log("External Login - No rows returned from test query.");
        return false;
    }

    Do we see that error in your logs?

    Get more information from the front end JS error
    We’re going to add a line of code to the front end JS so we can see more of what is going on.

    We’re going to modify the file wp-content/plugins/external-login/js/exlog_test.js.

    We’re going to add the line:
    console.log("EXTERNAL LOGIN JS TESTING:", xhr.responseText);

    We’re going to add this to the ajax call so that it looks like this:

                $.ajax({
                    type: "GET",
                    url: wordpressBaseUrl + "/wp-admin/admin-ajax.php",
                    data: data,
                    success: function (data) {
                        if (!data) {
                          errorMessageState(600);
                          $modal_error.show();
                        } else if (data == "") {
                          errorMessageState(601);
                          $modal_error.show();
                        } else if (data === "0") {
                          errorMessageState(501);
                        } else {
                          $modal_error.hide();
                          $modal_test_results.append(data);
                        }
                        $loader.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError){
                      console.log("EXTERNAL LOGIN JS TESTING:", xhr.responseText);
                      if(xhr.status == 404) {
                        errorMessageState(404);
                      } else if (xhr.status === 500) {
                        errorMessageState(500);
                      } else if (Math.floor(xhr.status / 100) === 5) {
                        errorMessageState(502);
                      } else {
                        errorMessageState(100);
                      }
                      $loader.hide();
                    }
                });

    Of course, this error will appear in your browsers console log.

    Plugin Author tbenyon

    (@tbenyon)

    Can you show me the PHP errors that happen at the time that you press the Test button.

    As you’re doing this testing on Mac I’m assuming you’re using Mamp to run this locally?

    If so, in menu bar I think there is an error logs option and PHP is an option within.

    Key here is there will be loads of stuff in there. I just want the stuff that appears when you click the button.

    Plugin Author tbenyon

    (@tbenyon)

    Ok, apologies for slowing down this process for you, I just worried we were going to waste your time by looking at the wrong solution.

    To get one thing solved at a time, let’s not worry about the plugin being installed on site A at the moment. Let’s just get Site B logging in using Site A users. For this we don’t even need the plugin installed on site A but just leave it there for now.

    On site B, try setting the hashing method to “phpcrypt” or “phpass”.

    I’m pretty sure WordPress uses one of these by default.

    Let me know how you get on 🙂

    Plugin Author tbenyon

    (@tbenyon)

    @xprojectsx – one more thing . . .

    Could you do a force refresh in your browser.

    Information on how to do this can be found here:
    https://www.getfilecloud.com/blog/2015/03/tech-tip-how-to-do-hard-refresh-in-browsers/#.XDtnWc-eRZI

    Plugin Author tbenyon

    (@tbenyon)

    Hey @xprojectsx,

    Are you still experiencing this problem?

    Could you tell me:

    • Which browser you’re using
    • Look at the browser console to see if there are any errors
    • Look in your database wp_options table and tell me what is stored in the field named “exlog_exclude_users_field_name_repeater”

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hey @piska,

    Before we start debugging the use of my plugin for this, I think you would be much better off looking at WorsPress multisite.

    Apologies if there’s a reason you’ve already diregarded this solution.

    Here’s a link I got from a quick Google:
    https://wpengine.co.uk/resources/wordpress-multisite-user-management/

    If it’s no what you’re looking for come back to me.

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hey @volt74,

    This is now live and other users have told me it’s working. If you have any issues, please feel free to re-open this ticket but I’ll mark it as resolved for now.

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    There are so many things to say here so I apologies for the long post:

    Migration
    Firstly, the plugin was written for using an external database as a the sole user handling and the plugin would just allow users in that system to access WordPress. I had not intended users to be able to be added in WordPress also and use the plugin as a migration tool.

    Having said that, this seems to be a worthwhile extension as you’re not the first to request this. I have a task in my backlog to support this but there are a lot of steps to make this happen smoothly.

    WP Member
    I am not going to add functionality that works with specific plugins as this will clutter the UI as every unique plugin that someone uses will need a custom section in the admin area and custom work from me.

    The way I can solve this for you is by adding in a hook. So that you can write custom code that will activate the user in your plugin at the point that they are authenticated by external login. I’ll just need to understand more about the flow which we can come back to.

    The code that would modify your plugin would be written in your functions.php file. Although people have managed to find me on Facebook or LinkedIn I am not allowed to offer or discuss private work on here but you could get any developer to do this bit if you are not comfortable with it.

    Summary
    I don’t know what your schedule on having this done is but this work isn’t going to be finished this month as I have a full time job and private work on the side. This is just a hobby for me and a service I provide for free.

    If you can wait I will schedule these tasks into my backlog and I can keep you posted on here of progress I’m making.

Viewing 15 replies - 466 through 480 (of 574 total)