Skip Navigation

[Resolved] Critical error from Toolset custom code

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)

This topic contains 2 replies, has 1 voice.

Last updated by katjaL 1 month, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2795567

Hi,
I added custom code in Toolset settings which I didn't unfortunately test and activated and now I can't login even in recovery mode, only "There has been a critical error on this website..."

Now I need to delete or deactivate the code I added, but I can't find where the Toolset custom codes are in the database. Would you please guide me to the right direction, thank you.

#2795573

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What custom code you are reffering to?

You can disable the code snippet by following the instruction given with the following link:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#disabling-the-code-snippets-feature

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2795575

Hi Minesh,

Thank you for the quick reply.

This is related to the custom code you wrote, I realized I need it with another view also and stupidly I just copied the code, and changed the view id. Didn't test, only activated and here we are. I realize now I should have changed the function name, right? Or even better I should have added the view with OR in the same custom code. I'm so novice at PHP.

Now I got the admin back (I didn't yet delete the toolset account) with this in config define( 'TOOLSET_DISABLE_CODE_SNIPPETS', true );
But of course the snippets aren't there and if I add the define( 'TOOLSET_DISABLE_CODE_SNIPPETS_GUI', true ); I can't get into admin.

I didn't yet delete the toolset user from this site. Do you have the credentials?

#2795576

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We do not store access details, once ticket is marked resolved the parivate accessa details automatically deleted.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2795582

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've removed the code from the snippet you added and I've adjusted the code added to "Custom Code" section with "toolset-custom-code" snippet as given under:

add_filter( 'wpv_filter_query', 'func_many_to_many_exclude_related_post', 101, 3 );
function func_many_to_many_exclude_related_post( $query_args, $view_settings, $view_id ) {
  global $post;
  $post_id = $post->ID;
  $relationship_slug = 'product-dokumentti';
  $exclude_doc_ids = array();
  
  $target_view_ids = array(58997,58991);
  
  if ( in_array($view_id,$target_view_ids) ) {
    
    $exclude_doc_ids = toolset_get_related_posts(
        $post_id,
        $relationship_slug,
        'parent',
        1000000,
        0,
        array(
        	array('meta_key' => 'wpcf-poista-tasta',
            'meta_compare' => '=',
            'meta_value' => '1')
        ),
        'post_id',
        'child'
        );
    
     if(!empty($exclude_doc_ids)){
       $query_args['post__not_in'] = $exclude_doc_ids;
     }
     
  }
   
  return $query_args;
}

You can add as many view IDs as you want to $target_view_ids variable.

#2795596

Brilliant! Thank you 🙂 Would you please let me know how you got the snippets visible to edit? I couldn't even get into admin.

#2795681

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've comment out the following line of the code on your wp-config.php file:

//define( 'TOOLSET_DISABLE_CODE_SNIPPETS', true );
#2795688

Ok, but when I did that, I couldn't get inside WP. There was this "There has been a critical error on this website..." Even recovery_mode didn't help. There's a way around that?

#2795722

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To get in to admin you have to uncomment that line and then I've deleted the unwanted code and modified the code I shared with you before so you will have working site.

Once site is working, I've comment out that code as we need to access the custom code section. I hope that clarifies things and this was not Toolset issue but you by mistake added wrong code.

#2796036

I'm sorry, but this is excactly what I don't understand how this was done:
"To get in to admin you have to uncomment that line and then I've deleted the unwanted code and modified the code I shared with you before so you will have working site. "

1. "To get in to admin you have to uncomment that line" - which line? If I uncomment "define( 'TOOLSET_DISABLE_CODE_SNIPPETS', true );" I definetly can't get in because of the error.
2. "and then I've deleted the unwanted code and modified the code" - how can you edit the code, if it's not there.

And yes, I understand the code error is not Toolset issue, it was my bad PHP. But the steps how to get back in and be able to edit the code would be Toolset issue, right?

#2796040

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1. "To get in to admin you have to uncomment that line" - which line? If I uncomment "define( 'TOOLSET_DISABLE_CODE_SNIPPETS', true );" I definetly can't get in because of the error.
===>
Yes - but I access the wp-config.php file by loggedin usnig FTP/SFTP and then you can add/remove the said line.

2. "and then I've deleted the unwanted code and modified the code" - how can you edit the code, if it's not there.
===>
As said - I've access those custom code snippet using FTP and deleted the unwanted code. There is no Toolset issue involved here. I did not know tht you were copy/paste same function.

In such cases you should login using FTP/SFTP and try to check the file where you see the error and fix it accordingly.

#2796065

Ok Minesh, this is the excact thing that I want Toolset answer since it's Toolset custom code:
You say: "As said - I've access those custom code snippet using FTP and deleted the unwanted code. "
Where is the Toolset custom code snippet (using FTP)? In which folder, what's the file name?

Thank you, I will not bother you more with questions when I get this info 🙂

#2796090

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Within "wp-content" folder you will see a folder namely "toolset-customizations" within that you will see all snippets you created using Toolset custom code.

#2796092

Perfect, thank you so much!