trying to conditionally use the hook
-
Hi, overall this is an amazing plugin but I’m trying to do something a bit more technical, I hope you can help.
I’m building a website using a custom built advanced custom field repeater to build blocks on a page – we have one page that’s just a domain checker, where it works perfectly.
We then have other pages where we are also promoting web packages, we’d like to combine the package and domain name into one purchase button – I am attempting to do this via the hook to modify the output of the results table using the hook you kindly provide
function change_whois_result( $whois_result ) { if ( in_array( $whois_result[‘tld’], array( ‘com’, ‘net’ ) ) ) { $whois_result[‘price’] = ‘4.99$’; $whois_result[‘link’] = ‘https://wp24.org/buy.php?d=%5Bdomain%5D&t=%5Btld%5D’; } return $whois_result; } add_filter( ‘wp24_domaincheck_whois_result’, ‘change_whois_result’ );
To try and only get this hook to work ONLY on specific pages I’ve added a custom field to the page called is_package_page – the idea being if this is checked it’ll then do the hook, but still can’t get it to work…
add_filter(‘wp24_domaincheck_whois_result’,?‘change_whois_result’);function?change_whois_result($whois_result)?{?// Ensure this logic runs only on the correct page and only if ‘is_package_page’ is enabled?if?(is_page() &&?get_field(‘is_package_page’)) {?// Modify the whois result only for certain TLDs?if?(in_array($whois_result[‘tld’],?array(‘com’,?‘net’))) {?$whois_result[‘price’] =?‘4.99$’;?$whois_result[‘link’] =?‘https://wp24.org/buy.php?d=%5Bdomain%5D&t=%5Btld%5D’; } }?// Return the modified or original whois result?return?$whois_result; }
If I just enter the hook it works, but on ALL forms. When I check the advanced custom field is registering on the specific page it is, I just can’t get the two to work.
Secondly, I’d like to modify the content of the button text as follows…
this is the current text for the purchase text in the plugin settings
[link][price] buy now[/link]I’d like the hook to edit the BUY NOW text, so it says BUY HOSTING AND GET A FREE DOMAIN NA<E
I hope you can help!
- You must be logged in to reply to this topic.