call custom action after delete account

It depends on what the function myAction() is doing. Your order is this: pluging defines action hook with do_action( ‘bp_members_delete_account_after_submit’ ); You hook a function on that with add_action( ‘bp_members_delete_account_after_submit’, ‘action_bp_members_delete_account_after_submit’ ); the function action_bp_members_delete_account_after_submit() is then adding a hook named ‘myAction’ and passing it two arguments as strings ‘arg1’ and ‘arg2’. But there is … Read more

add_action.. will work if function is empty?

The function will run, but nothing will happen. There is a small overhead, but you shouldn’t worry about it, the possible savings are minimal. Depending on when you have $checked available, you could also do function example() { echo ‘true’; } if ($checked) add_action(‘wp_head’, ‘example’);

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

Remove an action added within a class in a WordPress plugin

I finally managed to make it work : function remove_searchfield() { $tag = ‘epl_frontend_search_field_select’; // the name of the hook $function = ‘render_select’; // the function you wish to remove $priority = 10; // must be an integer remove_action ( $tag, array( Easy_Property_Listings::instance()->search_fields, $function ), $priority); } add_action( ‘init’, ‘remove_searchfield’); Thanks Jacob for the help … Read more

Run a function on all posts

Rather than hooking into init or wp_load, here is a snippet you can drop into functions.php or on a theme file. I put it behind a $_GET so that you can only hit it once and when you are ready. Something like https://domain.com/page/?update_post_meta // Hide it from the public if(isset($_GET[‘update_post_meta’])){ // Let’s query all of … Read more

W3TC manual cache flush does not work

The working solution is: <?php /* * Flushing the W3TC Plugin’s Cache entirely * @package WordPress */ ignore_user_abort( true ); include(‘/home/clients/<client-directory>/<website-directory>’ . ‘/wp-load.php’); w3tc_flush_all();

Action Scheduler not running

require_once( plugin_dir_path( __FILE__ ) . ‘/libraries/action-scheduler/action-scheduler.php’ ); /** * Schedule an action with the hook ‘eg_midnight_log’ to run at midnight each day * so that our callback is run then. */ function eg_log_action_data() { if ( false === as_next_scheduled_action( ‘eg_midnight_log’ ) ) { as_schedule_recurring_action( strtotime( ‘midnight tonight’ ), DAY_IN_SECONDS, ‘eg_midnight_log’ ); } } add_action( ‘init’, … Read more

comment_post callback function: how to run it in the background.

If you’re sending a redirect, then you can also just close the connection early and continue processing. wp_safe_redirect(‘http://example.com’); header(“Content-Length: 0”); header(“Connection: close”); flush(); do_something(); // continue processing whatever, user is already redirecting by now Reference: http://www.php.net/manual/en/features.connection-handling.php#104541 Read those user comments carefully, there’s some caveats there.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)