Jump to content

maxxd

Gurus
  • Content Count

    962
  • Joined

  • Last visited

  • Days Won

    24

Everything posted by maxxd

  1. Ah - OK. You can still use the WordPress WP_Query object (global $wpdb) to interact with the database, you'll just have to supply the table names yourself. Also, routing should still work as expected - if the correct rule is inserted in the rules array, you should be able to visit /kudos/JFMGTTQ5 and use get_query_var() to return 'JFMGTTQ5'. As far as an archive listing goes, I think you'll have to that yourself. Not trying to be nosy or pry, but is there a reason it's not set up as a custom post type?
  2. Also, I'm assuming quite a few things about your project that may not be true. I'm assuming, for instance, that kudos is a custom post type and you're trying to show both an archive listing of kudoses and single kudos records both. I'm also assuming that you're not wanting to show a kudos specified by URL parameter on a random page (for instance, here's 1 kudos record on the 'about us' page!). Each of these assumptions could very well change the overall approach; and even outside of all that, dealing with routing in WordPress is a convoluted and weird rabbit hole on it's own...
  3. What parse error is that throwing?
  4. It looks like your rule is slightly malformed. As I said earlier, I've found the add_rewrite_rule() function to be a bit fiddly - I try to use the 'rewrite_rules_array' filter instead. Try this: add_filter('add_rewrite_rules' ,'add_kudoskey_rule'); function add_kudoskey_rule(array $rules){ $new = [ 'kudos/([^/]+)/?$' => 'index.php?pagename=kudos&kudokey=$matches[1]', ]; $rules = array_merge($rules, $new); return $rules; } Now, with this in place you should be able to (after you've gone to the Permalinks page and clicked 'Save' to clear the rewrite cache) go to 'http://127.0.0.1/kudos/JFMGTTQ5' and it should show that specific kudos. If you want to get the kudos key referenced in the URL, use get_query_var('kudoskey'). If you want to show an archive listing of all kudos records, make sure that 'has_archive' is set to true in the arguments array of your custom post type registration call, then go to 'http://127.0.0.1/kudos' and you should see the listing. The whole point of adding a rewrite rule is to enable pretty URLs and to not have to use '?variableName=variableValue' because it's easier for the user and better for SEO.
  5. Look at the 'query_vars' and 'rewrite_rules_array' filter hooks as well - I've had varying degrees of success using either the add_rewrite_rules() function vs. just brute forcing the rewrite_rules_array array via those two hooks. I wish I could remember why, but it's late and it's been a long freaking week, so that information got purged. If I remember tomorrow I'll let you know, but in the meantime those two hooks are another way to go about skinning this particular cat that might be a bit easier to follow. Rewrites and routing can get confusing.
  6. Of course it won't work - you're not passing 'urlid' in this case. You're passing 'p'. Did you follow the link I put in the first post to the codex rewrite rules page? I think I'm still not getting what you're asking - even using post name as the permalink value in WP you can use URL parameters like normal. Just output the permalink, then append URL-encoded key/value pairs, then use them in $_GET.
  7. I'm confused by your question. In a URL, '?xx' is the first variable passed via GET, '&xx' is any of any number of variables passed in the URL after the first. So your desire to change '?urlid=abc123' to '&urlid=abc123' is solved by adding a variable before the urlid. What is the value of your permalink option in the Admin > Settings > Permalinks? If you're set to 'Post name' there are a few different things you can do. Obviously you can grab $_GET['urlid'] using an early-running hook and go if it's anywhere in the URL string. However, if you're saying that WordPress is removing the '?urlid=' part, that's a routing issue. You can set up routing in WP using the WordPress rewrite rules which will give you something along the lines of 'http://url.com/kudos/abc123' or 'http://url.com/urlid/abc123' depending on how it's all set up.
  8. Unless I'm reading that wrong, it seems to me that turning off autocomplete would be a heck of a lot easier all around.
  9. What is the header error? Output already started, not redirecting correctly, poking a badger with a spoon?
  10. I agree - I'm a bit baffled by the lack as well. I've emailed the third-party provider again about it, so hopefully they can shed some light. No, it throws a connection exception.
  11. That's the problem - as far as I can tell there's no WSDL endpoint for this. Thus far I've ended up basically building the request structure by hand and passing that into new SoapVars() using XSD_ANYXML as the encoding.
  12. Crap - I didn't even see that! Thank you - now to figure out how to get the namespace on the attribute.
  13. I've gotten the connection issues taken care of (as far as I can tell, it was a typo in the IP whitelist). However, I've got another "am I just totally asleep?" question. The endpoint expects these headers: POST /path/handler.asmx HTTP/1.1 Host: legit.com Content-Type: text/xml; charset=utf-8 SOAPAction: "http://givenNamespace.com/functionCall" Content-Length: 540 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <functionCall xmlns="http://givenNamespace.com"> <username>username</user> <password>password</pwd> </functionName> </soap:Body> </soap:Envelope> and this is what I get from __getLastRequestHeaders() and __getLastRequest() after my __soapCall() call: POST /path/handler.asmx HTTP/1.1 Host: legit.com Connection: Keep-Alive User-Agent: PHP-SOAP/7.2.19 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://givenNamespace.com/functionCall" Content-Length: 540 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <functionCall xsi:type="SOAP-ENC:Struct"> <username xsi:type="xsd:string">username</user> <password xsi:type="xsd:string">password</pwd> </functionName> </SOAP-ENV:Body> </SOAP-ENV:Envelope> It's been a while since I've dealt with a non-WSDL API endpoint but am I crazy that my headers should work? Because I'm getting the following error: "Server was unable to process request. ---> Handler.loginNoSession(): DB Exception: Couldn't login. ErrorCode = 0 ---> Procedure or function 'checkUserPassword' expects parameter '@User', which was not supplied." And I feel like kind of an idiot about it. I'm assuming (because it seems rather obvious) that checkUserPassword is a stored procedure that gets passed the value of the 'user' parameter submitted in the Soap call, but apparently the middleware's not recognizing that I am passing the user parameter.
  14. From the office system it works fine when the username/password is appended to the URL. I'm wondering if there was a snafu in the IP whitelist where our office was whitelisted correctly but the development system wasn't. I've got an email in with the provider to find out, just wanted to post here in case there was something glaringly obvious that I just yawned over...
  15. Hey, 'all. I think I'm just tired because I can't see the issue here, but I'm trying to run a SOAP 1.2 call to a legit endpoint using a legit function call and getting nothing but a 'Could not connect to host' message with a fault code of 'HTTP'. Here's some code: class Testing{ private $_user = "username"; private $_pass = "password"; private $_system = 1; private $_uri = "http://legit.com/endpoint/"; private $_location = "givenlocation.asmx"; private $_soapClient; public function __construct(){ $this->_soapClient = new SoapClient(null, [ 'location' => "{$this->_uri}{$this->_location}", 'uri' => $this->_uri, 'soap_version' => SOAP_1_2, 'exceptions' => true, 'trace' => true, ]); } public function makeCall(){ try{ $data = $this->_soapClient->__soapCall('functionCall', [ 'username' => $this->_user, 'password' => $this->_pass, ]); }catch(SoapFault $e){ die("<pre>".var_export($e, true)."</pre>"); } } } $testSoap = new Testing(); $testSoap->makeCall(); I'll happily take a "Let me Google that for you" result link if it's that simple, but I'm just not seeing the problem. Anybody? As always, help is greatly appreciated. Forgot to mention - I don't get an error on instantiation of the SoapClient() object, just the __soapCall() call.
  16. All WordPress AJAX requests are routed through admin_ajax.php. You need to supply an 'action' index in your passed array, then use the 'wp_ajax_{your-action}' and 'wp_ajax_nopriv_{your-action}' hooks. See here for further information.
  17. So, clearly you're working with WordPress for this project. WordPress has enough issues and pain points by and of itself - why are you making it harder on yourself? If you're actually (as it seems) working within the WP infrastructure, why not just use the WordPress database object? The connection to the database is already made, you can use it like an ORM (kinda), and depending on how you use it, it kinda sorta sanitizes database interactions by default. The reason you'll see a check in most WP theme and/or plugin files for the ABSPATH constant is to make sure the WordPress core has been loaded. If you're trying to do something within WordPress before the core is loaded, I'd recommend looking at why you're trying to do it and why it needs to be done exactly then. I hope that makes sense, and sorry if I'm missing the point of what you're actually trying to do, but it really seems like you're making things much more difficult than they need to or should be.
  18. Also, part of the joy of prepared statements is that you only need to prepare them once. Do the PDO::prepare() outside the loop, then bind the variables and run the query in the loop. Which, again, we can't see.
  19. Nothing in your code shows a loop. If there's a loop inserting data but the only data being inserted via that loop is the last row of data, then there's probably a problem with the loop; which we haven't seen.
  20. Create a variable called "$currentSalesRep". At the start of your while loop, grab the current record's name field and compare the value to $currentSalesRep. If the values are different, create a new worksheet then store the current record's name value in $currentSalesRep.
  21. PHP is a server-side language. You're going to want JavaScript so as to handle things on the client side. Check out https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API
  22. Check this list out. I think it's probably not exhaustive, but it should be big enough to get you started.
  23. Put the code from the example in your child theme's functions.php file. I assume you're using a child theme - if not, create one and then do it. You don't want to modify any plugin or pre-built theme files directly as those changes will be overwritten every time the plugin or theme updates. Now, that having been said, you can't just copy and paste the example code - you'll have to modify it to fit your purposes. For instance, the example code checks for any fields with an ID of 100, 101, or 102 before running the rest of the logic. The likelihood that the fields you're looking to compare against are ID 100, 101, or 102 is slim...
  24. Explode the string on newline and you'll have an array of emails which you can loop through to insert. You may want to run additional checks for commas and/or whitespace just in case your users don't read the instructions.
  25. This seems like a good place to start.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.