Woocommerce redirection to checkout for certain after product added to cart

I have implement this code in function.php to redirect the page to checkout if product with id(26285) added to the cart .This is the code

add_action( 'woocommerce_add_to_cart', 'custom_add_to_cart', 1, 2 ); function custom_add_to_cart( $  cart_item_key, $  product_id ) {  $  site_url = get_site_url(); if($  product_id == 26285) {  // Redirecting to some url wp_redirect($  site_url.'/my-account/'); exit; }} 

the condition i need to satisfy here is , if the product with ID:26285 added to the cart i need to redirect to checkout.The problem i am facing now is the page is redirecting but the product was not adding to cart . How to achive that?

Your help will very much appreciated. Have a nice day!

Why certain sites don’t send newsletters to “anonymous” mail addresses?

I use an “anonymous” mail address (cock.li provider in my case). I have found that mainstream news sites in particular don’t send their newsletters to such an addresses. It looks like the domains blacklisted.

What is the reason? I can understand that they don’t want you writing comments from anonymous mail addresses, but passive reading of a newsletter is also prohibited?

Why this behavior? Why this behavior only with traditional mainstream news?

These newsletters usually have a lot of advertising and tracking, why they don’t wish to deliver them to “anonymous” addresses?

Proving a certain primitive recursive function exists

Assume $ f\colon ω × ω → ω$ is a computable function. How can we prove that there is a primitive recursive function $ g\colon ω × ω → ω$ where the following holds:

$ ∀n [∃s(f(n, s) = 1) ↔ ∃k(g(n, k) = 1)]$

So for every $ n$ , there is an $ s$ such that $ f(n, s) = 1$ if and only if there is a $ k$ such that $ g(n, k) = 1$ .

Been working on this problem for a while now, if anyone could please help?

Display all videos on separate page from certain ACF field

I am using Elementor and ACF. Using ACF I created oEmbed field for adding videos for each post. Idea is to show all uploaded videos on separate page.

So on separate video page I want to display all videos related to this ACF oEmbed field from all posts.

I’ve tried with Elementor Custom Skin plugin, but two problems. Video UI is not like on Vimeo and another problem is display empty fields, so I have empty div elements, but I’ve add conditionals logic and still problem.

Is there a way to limit cookies to certain hosts in HTTP?

Using Nginx, I hope to restrict the permissible hosts for cookies. My initial intention was to employ a Content Security Policy for this purpose, but I don’t see an obvious way to do this via a CSP. Ideally I’d find something like

Restrict-Cookies-Header: hostname1.tld hostname2.tld2 

Can something like this be accomplished with HTTP headers? Thanks!

Send push when new post is published in a certain category

I’m trying to develop a plugin which send a push notification to an app users, when a new post is published on a certain category. I’m trying with the hook save_post, but when the hook is fired, the post has no categories. I try in_category(2) function, but it always return false. I try wp_get_post_categories($ post_id) but always resolve to no categories and the same with wp_get_post_terms($ post_id, 'category')

I dont know if save_post hook is the correct, I think it’s fired before the categories are asociated to the post.

How I know if the post is published in a certain category?

For certain URI, is it possible to log the rule violation instead of returning access deny?

We have set up Modsecurity CRS with Nginx (it is awesome!), and we are in the phase of customization (or writing the exclusion rules). We’d like to know if it is possible that modsec can only log the exception for certain URIs without adding up the score while the rest of the URIs still being protected. Or, whenever it tries to return Access Deny, it will check if it for certain URIs first. I’ve read a couple of tutorials and they suggest either setting detection mode or the threshold to a huge number, while we’d like to start the protection now but don’t want to affect certain URIs as they are critical for business. If modsec finds rules violation for those URIs, we’d like modsec to log it only and we’ll write exclusion rules after reviewing the logs. Thanks.

Modsec verion: v3.0.3

Nginx version: 1.13.6

Can certain classes replace cantrips with other spells when they level up?

Many classes: bard, ranger, sorcerer, and warlock have this type of text in their Spellcasting or Pact Magic feature under Spells Known of 1st Level or Higher:

Additionally, when you gain a level in this class, you can choose one of the spells you know and replace it with another spell from the spell list, which also must be of a level for which you have spell slots.

Can I choose to replace cantrips or only spells of 1st level or higher?

How to exploit this C program to call a certain function?

The goal is to call the function foo in the following program:

struct object {     unsigned char buf[36];     void (*fp)(); };  void baz(struct object * obj, unsigned int num) {     for (int i = 0; i < num; i++) {         unsigned int x;         scanf("%d", &x);         if (x == 0) break;         obj->buf[i] = x & 0x000000ff;     } }  void foo() { // target }  void bar() { }  int main() {     setvbuf(stdin,  NULL, _IONBF, 0);      setvbuf(stdout, NULL, _IONBF, 0);      setvbuf(stderr, NULL, _IONBF, 0);      struct object * obj = malloc(sizeof(struct object));     memset(obj->buf, 0, 36);     obj->fp = &bar;      int num;     scanf("%d", &num);     if (num > 36) {         num = 0;     } else {         baz(obj, num);     }      for (int i = 0; i < num; i++) {         printf("%d. \t", i + 1);         for (int j = 0; j < obj->buf[i]; j++) {             printf("*");         }         puts("");     }      obj->fp();     free(obj); } 

My thoughts were to modify fp in obj (which is called at the end) such that it points to foo instead of bar. By entering a negative number for num such that it becomes a large positive number when casted to unsigned int in baz, this should allow the modification of fp by overflowing buf in obj. However, this would require the address of foo which changes every time the program is run.

I would appreciate any ideas or hints to solve this problem.