Skip Navigation

[Waiting for user confirmation] 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 Minesh 4 hours, 12 minutes 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.