schedule event in class oriented plugin

This reason, and others (removing a hook for example) is why you should use for hooks only plain functions or static functions. OOP in plugins and themes rarely has anything to do with proper OO. If you use it as a way to have a separate namespace, then just use a namespace.

How to cancel the trash action inside wp_trash_post

It’s possible to utilize the pre_delete_post filter to short-circuit the deleting of posts. add_filter( ‘pre_delete_post’, ‘wpse_224246_pre_delete_post’, 10, 3 ); function wpse_224246_pre_delete_post( $delete, $post, $force_delete ) { //* Escape early if post isn’t already trashed if( ‘trash’ !== $post->post_status ) { return $delete; } //* Go ahead with deleting the post if the current user is … Read more

Custom Front End Registration – How Does the Key work in the Password Set Request?

Because I couldn’t find an answer on this, I handled it myself by setting my own cookie in the function and checking that. Here is the revised function: function custom_login_init () { $action = isset($_REQUEST[‘action’]) ? $_REQUEST[‘action’] : ‘login’; if ( isset( $_POST[‘wp-submit’] ) ) { $action = ‘post-data’; } else if ( isset( $_GET[‘reauth’] … Read more

Register form: add custom field BEFORE default fields

You can’t, because of wp-login.php structure. Here is code with register_form hook: <form name=”registerform” id=”registerform” action=”<?php echo esc_url( site_url( ‘wp-login.php?action=register’, ‘login_post’ ) ); ?>” method=”post” novalidate=”novalidate”> <p> <label for=”user_login”><?php _e(‘Username’) ?><br /> <input type=”text” name=”user_login” id=”user_login” class=”input” value=”<?php echo esc_attr(wp_unslash($user_login)); ?>” size=”20″ /></label> </p> <p> <label for=”user_email”><?php _e(‘Email’) ?><br /> <input type=”email” name=”user_email” id=”user_email” class=”input” … Read more

Redirect in form handler causing form to be submitted twice

You can fix it through Session. try function vv_process_profile_forms() { session_start(); if ( isset( $_POST[‘action’] ) && $_POST[‘action’] == ‘profile-form’ ) { if ( ! isset( $_SESSION[‘form-submit’] ) ) { // form processing code here $_SESSION[‘form-submit’] = 1; $redirect_page = get_permalink( 586 ); wp_redirect( $redirect_page ); exit; } else { unset( $_SESSION[‘form-submit’] ); } } … Read more

Hook when editing user

Yes, this is CORRECT add_action(‘edit_user_profile’, ‘limpiamosVariables’); function limpiamosVariables($user){ // My Code Sample update_option( “var_ios_token”, get_field(‘token_user’, ‘user_’.$user->id) ); };

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