How to correct schedule my event weekly with wp_schedule_event()

According to the docs for this function, you can’t set up a weekly event by default. wp_schedule_event(int $timestamp, string $recurrence, string $hook, $args = array() ); The $recurrence value needs to be one of: “hourly” “twicedaily” “daily” You’ll need to test today’s date inside your callback function, my_event. Something like: function my_event() { # date(‘l’) … Read more

How to output a permanently delete comment link?

After briefly testing, the code snippet from OP seems to work: printf( ‘<a href=”https://wordpress.stackexchange.com/questions/269898/%s”>%s</a>’, wp_nonce_url( admin_url( “comment.php?c=$comment_id&action=deletecomment” ), ‘delete-comment_’ . $comment_id ), esc_html__( ‘Delete comment’, ‘text-domain’ ) ); But it looks like we have to make sure that the author is only deleting comments on hir own post, otherwise it will look for the edit_others_posts … Read more

How to auto login user again after change user_login

I found when attempting similar I needed to clear the user cache to get the relogin to work (after much frustrating testing!): wp_cache_delete($user_id, ‘users’); wp_cache_delete($old_user_login, ‘userlogins’); // maybe unnecessary? $creds = array(‘user_login’ => $user_login, ‘user_password’ => $user_password, ‘remember’ => true); wp_signon($creds); Note for this to work you may also need the user to change their … Read more

Dynamic URL to reference custom PHP files

I’m not positive I understand the question, but if you’re just trying to get the site URL, you can use the get_site_url() WP function. So, like this: $siteURL = get_site_url(); header(“=Location: $siteURL” . “/myoriginalformpage/?success=”, $success); And you can change the parameters of get_site_url() to specify the path and to display ‘https’ or ‘http’. But if … Read more

How to get year, month and hour in WordPress?

PHP Date Format in WordPress function: You’ll have to use the proper date format string (as used in PHP date function) in the WordPress get_the_date() function’s first parameter. For example, to get the Date & Time in the format like 2018-07-23 23:59 (i.e. YYYY-MM-DD HH:MM, where hour is in 24 hour format), you need CODE … Read more

Custom post type column which compares dates?

I solved it: if ( ‘visitor_active’ == $column_name ) { $start_date = get_post_meta( $post_id, ‘visitor-start-date’, true ); $end_date = get_post_meta( $post_id, ‘visitor-end-date’, true ); $current_time = current_time( ‘timestamp’ ); if ($start_date < $current_time && $end_date > $current_time) { echo ‘<span class=”dashicons dashicons-yes” style=”color:#75c377;”></span>’; } else { echo ‘<span class=”dashicons dashicons-no” style=”color:lightgray;”></span>’; } } Don’t know … Read more

add_filter to post-gallery and remove all ‘s?

EDIT: you must call your filter after the shortcode is processed, giving it priority > 10, and you must match on a multiline expression. Try this work with my installation and using the standard gallery shortag: add_filter( ‘the_content’, ‘remove_br_gallery’, 11, 2); function remove_br_gallery($output) { return preg_replace(‘/<br style=(.*)>/mi’,”,$output); }

problem with ajax and the path to the php page

To use the WordPress ajax url you can pass the var using wp_localize_script: wp_enqueue_script( ‘functions’, get_bloginfo( ‘stylesheet_directory’ ) . ‘/js/functions.js’, array( ‘jquery’ ), false); wp_localize_script( ‘functions’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) ); In your functions.js $.ajax({ type: “POST”, url: MyAjax.ajaxurl, data: {p:alt_p}, success: function(data) { alert(data); } });