jlknauff
Forum Replies Created
-
Forum: Hacks
In reply to: How to use cookies within WP?Hmmm…well, I have add_action() but not add_filter(). Should both be there? If so, where should add_filter() go?
Right, when I nav to the appropriate page, it works fine, and it works fine on all of its sub pages, but when I go back up to page further up the tree, then that data goes away.
I’m open to using JS if that would be a better option…
I’ve found this https://www.w3schools.com/js/js_cookies.asp which looks like it *should* fit the mission, then I just need to pass the data to php so WP can use it. If I’m on the right track with that, let me know. I know next to nothing about JS.
Thanks for your help so far!
Forum: Hacks
In reply to: How to use cookies within WP?The cookie is there, as I am logged into WP and remain logged in from page to page, but the $_COOKIE[‘localphone’] no longer exists.
No, not redirecting to another page to store the cookie – when a visitor arrives on a page for a local branch, the page plugs the local data into the cookie, in this case, the local phone #, and as long as you nav to the sub-pages of that page, it works fine, but when you go to one of the pages above it, the cookie loses $_COOKIE[‘localphone’].
Does that make better sense?
When you mention “hooking” the filter, I have a basic idea of what you’re saying, but I’m not sure how. I had put the php to set the cookie into the functions.pp; shouldn’t that do it?
Forum: Hacks
In reply to: How to use cookies within WP?The reason I ask is I’ve tried sending it via WP, using the functions.php, which is loaded before any of the template files, but data is still always deleted from the cookie the next page I go to.
Forum: Hacks
In reply to: How to use cookies within WP?Hmmm…the WP flow seems to be what’s screwing it up (based on my capabilities, nothing “wrong” with WP), might JS be a better option in your opinion?
Forum: Hacks
In reply to: How to use cookies within WP?Right, I’ve tried placing that in a bunch of location; on the page, in the header, even in functions.php but once I go back to one of the other pages, that value is no longer in the variable.
As example below from functions.php:
function set_newuser_cookie() { if (!isset($_COOKIE['localphone'])) { $localphone = get_post_meta($post->ID, "phone", true); setcookie('localphone', $localphone, time()+3600); } } add_action( 'init', 'set_newuser_cookie');
Is there something else I should be aware of?
Forum: Fixing WordPress
In reply to: Creating a link from post titleOoops…typo. That’s what happens when I stay up all night. I missed the echo ??
Forum: Fixing WordPress
In reply to: Creating a link from post title<a href="https://www.google.com/search?q=<?php the_title(); ?>"Click Here</a>
Forum: Hacks
In reply to: data validation toubleI think I found a solution. I instead escaped the elements that make up the search criteria, and then passed the sanitized data to the query.
Any holes in this approach?
Forum: Hacks
In reply to: $wpdb->updateI found the solution – I replaced the two items that the WHERE statement was using with an array of the two values and now it works fine.
Example:
$wpdb->update('wp_network_members', $insert_member_data, $insert_member_data_match);
Forum: Hacks
In reply to: $wpdb->updateI realized I was missing a comma and don’t seem to need the single quotes on the field names, but I’m still getting the same error. Here is my updated line of code:
$wpdb->update('wp_network_members', $insert_member_data, WHERE f_name = $insert_member_data['f_name'] AND l_name = $insert_member_data['l_name']);
Forum: Hacks
In reply to: $wpdb->insert isn't working for me…Found the problem and it works perfectly now! Thanks ??
Forum: Hacks
In reply to: $wpdb->insert isn't working for me…As far as I can tell, none of the array keys are reserved words with MySQL
[f_name]
[l_name]
[title]
[company_name]
[company_description]
[countdown]
[rss]
[twitter]
[facebook]
[linkedin]
[email]
[phone]
[fax]
[address_1]
[address_2]
[city]
[state]
[zip]
[photo]
[logo]
[join_date]I even added a prefix (netmemb_) to each field and updated the code accordingly, but the row still won’t insert.
Is there anything else I should be looking for?
Forum: Hacks
In reply to: $wpdb->insert isn't working for me…Also, it mentions on the page https://codex.www.ads-software.com/Function_Reference/wpdb_Class that you shouldn’t SQL escape the data
(array) Data to insert (in column => value pairs). Both $data columns and $data values should be “raw” (neither should be SQL escaped).
but since this data is coming from a form, wouldn’t that be dangerous?
Forum: Hacks
In reply to: $wpdb vs. $post ?Does anyone have a way to pull the data I need from $wpdb instead of using $post->post_title ?
Forum: Hacks
In reply to: Where is page template info in database?Ahh…I figured it was in wp_postmeta but couldn’t find it…turns out it’s using the page template FILE name rather than the name declared in the page template.
Thanks, you saved me from a few more gray hairs ??