Pass variable to hook. Its possible?

Ok i can pass variables to hook but i was doing it wrong. Code should be: function encrypt_password_function($pass, $id){ global $wpdb; $encrypted=sha1($pass); $wpdb->query($wpdb->prepare(“UPDATE wp_users SET iphone_pass = %s WHERE ID = %d”,array($encrypted, ’10’))); } function encrypt_password($var1, $var2) { do_action(‘encrypt_password’,$var1, $var2); } add_action(‘encrypt_password’, ‘encrypt_password_function’, 1,2);

Need to check is_archive during init

This is what I could come up with, within init like you said ! Even if you print the $GLOBALS array, there is no way to check if the current page is an archive, is_archive is also set to blank! But if you check the $_GET array, the q variable contains the current archive type … Read more

Where should I hook into admin?

Not sure about the Membership plug-in bit, but admin_init will be your best bet. I assume that you don’t actually what to hook into the admin header though – this would be admin_head or admin_head-(plugin_page) – but you cannot redirect after these hooks (headers already sent).

Which action does wp_update_user triggers?

wp_update_user() is in /wp-includes/user.php lines 1401-1439. It uses wp_insert_user() (same file, lines 1254-1380) to update the existing user or add a new one if the user doesn’t exist. That function is where the various filters and actions affecting user account info live, and shows everything you can do to the $user object.

Looking for a hook for post.php

You can add your code to the init action hook and check global $pagenow variable: add_action( ‘init’, ‘wpse8170_check_from_var’ ); function wpse8170_check_from_var() { global $pagenow; if ( ‘post.php’ != $pagenow || ! isset( $_GET[‘post’] ) || ! isset( $_GET[‘from’] ) || 1 != (int) $_GET[‘from’] ) { return; } update_post_meta( (int) $_GET[‘post’], ‘EDITED’, ‘true’ ); }

Plugin init hook

There’s the plugins_loaded hook for normal Plugins and muplugins_loaded, which runs earlier. My best advice for hooks is making cross file searches for do_action or dump the content of the all hook with $GLOBALS[‘wp_filter’][ current_filter() ];.

Hook when new CPT published AND postmeta inserted

I believe you can do it using the save_post hook, than do a conditional check for the post’s post-type and the value of its post meta. add_action( ‘save_post’, ‘do_some_function’); function do_some_function($post_id) { global $post; $post_type_as_taxonomy = array(‘cpt-1′,’cpt-2′); // this is your hooked custom post types $post = get_post( $post_id ); if(in_array($post->post_type, $post_type_as_taxonomy) && $post->post_status==’publish’){ // … Read more

Strange behaviour with add_{$meta_type}_metadata | add_post_metadata filter

Ok I’ve found the solution… I have had to call add_filter outside my plugin class, because of WordPress hooks priority. With the actual code, I call add_filter after the ‘init’ event, that’s probably too late. If I move this line of code: add_filter(‘add_post_metadata’,array(&$this,’filter_negozi_add_metadata’),10,5); on top of the file, the hook works like expected. So to … Read more