Prefix user login_name and validate it is unique on Registration

The usual way to create a user goes with the register_new_user function. This function offers no filter for the user name. It just checks for uniqueness with username_exists. To actually create the user register_new_user then calls wp_create_user, which in turn calls wp_insert_user. The latter function contains the pre_user_login filter. Then it calls username_exists again, because … Read more

‘At a Glance’ dashboard: combining infos

dashboard_glance_items is a filter hook, not an action hook. See here for an explanation of the difference. Your at_glance() function doesn’t include the existing values, so only the items you return will be present in the At A Glance widget items. Something more like this: function at_glance( $items ) { $number_users = count_users(); $text = … Read more

How to check if we are in the init hook?

You can use did_action to test for this, e.g.: if ( did_action( ‘init’ ) < 1 ) { // init has not ran yet! Throw the exception } https://developer.wordpress.org/reference/functions/did_action/ did_action returns the number of times that action has been run. This can also be used to ensure it only happens once for filters that happen … Read more

Search WordPress Hook for completed Elementor Update

If I understand correctly, you want to do this: add_action(‘upgrader_process_complete’, ‘my_clear_elementor_cache’); function my_clear_elementor_cache() { // Make sure that Elementor loaded and the hook fired if (did_action(‘elementor/loaded’)) { // Automatically purge and regenerate the Elementor CSS cache \Elementor\Plugin::instance()->files_manager->clear_cache(); } }

Hook on opening a media/document

I am trying to find a hook to be able to set a datalayer.push everytime a document is opened. It could even be something that runs after the document is opened ex: https://proximite-courtage.fr/wp-content/uploads/2022/06/LISTE_PARTENAIRES_PC_22062022.pdf No. WP isn’t running when you visit PDF files directly via their URL, so there is no PHP loaded and no opportunities … Read more

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