Home › Toolset Professional Support › [Resolved] custom code snippets is no longer working
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Types plugin, Views plugin
This topic contains 15 replies, has 2 voices.
Last updated by Minesh 4 years, 2 months ago.
Assisted by: Minesh.
Hi, I have an active custom code module in custom code snippets which was working and now has stopped , it's as if custom code snippets has been deactivated. Shane was checking a bug for me which he traced to this module, I'd now like to debug it, but custom code snippets is no longer working.
How can I activate it?
Thanks
Hello. Thank you for contacting the Toolset support.
Basically, you can activate/deactive the code snipped you added from the "Custom Code" section:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/#activating-a-code-snippet
I wonder yet what custom code snippet you want to activate and where you added that? Can I have more information about your issue and once I can see what is the issue, I can help you with that.
However - I checked the previous ticket you have and I found this:
=> https://toolset.com/forums/topic/displaying-child-posts-with-parent/page/2/#post-1810415
- Are you talking about that code snippet - do you have it already added now?
Hi Minesh,
Yes the code snippet from the previous ticket is the one I'm talking about. I deactivated it to check that was the problem - it was.
So I activated it with the intention of checking the code, but now when I run the View where this code snippet should be used the code doesn't run.
Thanks
- Can you please make sure that the you added the correct view ID within the code snippet so it should target the view you want.
- can you please make sure that the code snippet is active
If both of the above cases are true, I will require problem URL where you added the view as well as access details and you should also share the link where I can see the code snippet you added.
I have set the next reply to private which means only you and I have access to it.
I checked on your install and I found that you added multiple functions with the same function name.
Please make sure that when you copy/past the wpv_filter_query code, you should also change the associated function name.
Can you please check now if this works for you?
Hi Minesh,
Thanks for your reply, sorry not clear where the duplicate function names are, I'm using the medicinal use search view - hidden link which doesn't have any query filters and should use code snippet medicinal search - but doesn't
Thanks
Yes - I can see the issue and I'm not sure whats going on here.
I checked the FTP access details you shared but its not working at this end. Can you please send me working FTP access details and I will try to troubleshoot further.
I have set the next reply to private which means only you and I have access to it.
It seems your plugin your theme hijack the priority of Custom Code snippet you added to "Custom Code" section offered by Toolset.
I've just added the following code to your theme's functions.php file:
/* Toolset custom Code */ add_filter( 'wpv_filter_query', 'func_filter_complaints_view', 99,3); function func_filter_complaints_view( $query_args,$view_setting,$view_id ) { if($view_id == 19221){ echo "<pre>"; print_r($query_args); exit; } }
And when I checked the link on the forntend I can see its working:
=> hidden link
Also, please update ALL Plugins+theme you are using.
Hi Minesh,
Not clear what you mean by
"It seems your plugin your theme hijack the priority of Custom Code snippet you added to "Custom Code" section offered by Toolset."
Was the site hacked? do I need t add extra security?
When you say update all plugins and theme does that mean remove and reinstall?
Attached screen is what I see when I checked - what is this telling me? Do I need to remove this from functions.php?
Thanks for your help
David
"It seems your plugin your theme hijack the priority of Custom Code snippet you added to "Custom Code" section offered by Toolset."
Was the site hacked? do I need t add extra security?
==>
No , I mean to say that the code you added to "Custom Code" section is not get executed as I suspect there is some higher priority of some other plugins hook/actions but it can be anything.
That is why I've added the code to your current theme's functions.php file and I can see it get executed.
When you say update all plugins and theme does that mean remove and reinstall?
==>
You can update plugins from the plugins page or yes you can remove it, download the latest version of your theme or plugin and reinstall it.
Attached screen is what I see when I checked - what is this telling me? Do I need to remove this from functions.php?
==>
Yes, you see that because we added the code to functions.php file and the code we added is executed now so you can adjust the hook code now as per your requirement.
Hi Minesh,
If I understand you're saying I should move the medicinal use search from Toolset custom code to functions.php.
If that's correct, do I need to make any changes to the code when moving it to functions.php
Thanks
As said, I show you working example, now you should try to adjust the code as per your requirement.
Hi Minesh,
Could you please show me the code to convert the working example code that you added to functions.php to a plugin and include the add_shortcode function.
Thanks
Do you mean you want to add a sample example custom shortcode to functions.php file? If yes:
- Please check the following guide:
=> hidden link
Hi Minesh,
I want to make a stand alone plugin, so something like:
<?php /* Plugin Name: Toolset custom Code Plugin URI: <em><u>hidden link</u></em> Description: Search Complaint use, Biological System, Medicinal actions for any or all search terms Version: 1.0 Author: david */ add_filter( 'wpv_filter_query', 'func_filter_complaints_view', 99,3); function func_filter_complaints_view( $query_args,$view_setting,$view_id ) { if($view_id == 19221){ echo "<pre>"; print_r($query_args); exit; } } add_shortcode('med_use', 'func_filter_complaints_view'); ?>
And install it to wp-content/plugins/toolset-custom-code/toolset-custom-code.php
Then to run in the page:
[med_use]
Is this ok?
Thanks