WordPress cronjob get scheduled but function does not run

I believe you need to use wp_get_current_user() (see https://codex.wordpress.org/Function_Reference/wp_get_current_user ), which will return the current WP user information as an object. From there, you can get the user name (or other parameters). From that page, this example should get you started: $current_user = wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( … Read more

Issues with if, else, and elseif statements

Here is an alternative solution. I think it would be cleaner than adding all these if statements and page IDs. You can do this using CSS and the body class WP adds. For example, go to one of your single pages and look at the class on the body tag. You should see something like … Read more

Getting the post ID in parse_query

Thank you for your responses. After a bit of testing, I hooked onto WP (https://developer.wordpress.org/reference/hooks/wp/) which occurs near the end of the WordPress loading sequence, and it is now working: function wf_lang_query_check() { global $wp_query, $post; $lang = wf_get_lang(); if ( ( !is_admin() && $wp_query->is_main_query() ) && ( $lang && ( !in_array( $lang, wf_valid_lang() ) … Read more

How to execute a hook asynchronously?

Yes, that’s what the WP Cron system does. It will fire an action/hook as close to a requested time as it can, and can do it once or multiple times. You would still have a hook that runs on profile_update but it wouldn’t send data to google spreadsheets, rather it would schedule a cron job … 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 perform action when plugin/theme editor is used?

The ajax action that runs on theme or plugin update is edit-theme-plugin-file so you should be able to hook into it by running code on the wp_ajax_edit-theme-plugin-file hook. add_action(‘wp_ajax_edit-theme-plugin-file’, ‘log_cowboy_coders’); function log_cowboy_coders() { $user = get_current_user_id(); if (!empty($__POST[‘theme’])) { // Log that someone is editing a theme } else if (!empty($__POST[‘plugin’])) { //log that someone … Read more

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