Init action and refresh page after form action

From the documentation: https://developer.wordpress.org/reference/hooks/init/ add_action( ‘init’, ‘process_post’ ); function process_post() { if( isset( $_POST[‘unique_hidden_field’] ) ) { // process $_POST data here } } In your example, perhaps having two different add_action is causing problems and burying your function where it’s not firing during init I’m going to test a similar solution and see what … Read more

Hook for inserting?

If you have access to the database, you could potentially create a trigger for that plugin-specific table. This bypasses the need for a hook. Depending on how they handle database schema updates, it might even stick around after a plugin update. I’ve never tried triggers on WP tables though, so take this with a grain … Read more

How to properly refresh page after form action?

Searching around and not being able to implement the action through init hook I’ve found this workaround which for sure isn’t the best but does the job nicely. echo “<script type=”text/javascript”> window.location=document.location.href; </script>”; at the end of $_POST instructions. If somebody has a better solution, welcome to share.

How to access deleted term inside delete_product_cat action

You get 500 error, because you’ve added your filter incorrectly… It takes 4 params, but you register it as it was using only one. add_action(‘delete_product_cat’, ‘sync_cat_delete’, 10, 1); // 10 is priority, 1 is number of params to take function sync_cat_delete($term, $tt_id, $deleted_term, $object_ids){ var_dump($deleted_term); } So if you change that 1 to 4, it … Read more

Display attribute on shop page after the title

add_filter( ‘the_title’, ‘YearOfMake’, 10, 2 ); function YearOfMake( $title, $post_id ) { if ( get_post_type( $post_id ) != ‘product’ && ! is_archive() ) return $title; if ( ! ( is_shop() || is_product_category() || is_product_tag() ) ) return $title; /* global $product; $attribute=”year-made”; $abv = $product->get_attribute($attribute); if(!empty($abv)) { $title .= ‘<br /><p>’ . $abv . ‘</p>’; … Read more

add_action( ‘publish_pelicula’, ‘post_published_notification’, 10, 2 ); does not trigger propperly

Well let’s compare the hook to one that is working: add_action( ‘admin_init’, array( $this, ‘page_init’ ) ); add_action( ‘publish_pelicula’, ‘post_published_notification’, 10, 2 ); page_init() and post_published_notification() are both methods of the MySettingsPage class, but you’ve set the action callbacks for each of them differently. The second argument for add_action() is a callback. It tells WordPress/PHP … Read more