Having an add_action( ‘user_new_form’,) [closed]
Having an add_action( ‘user_new_form’,) [closed]
Having an add_action( ‘user_new_form’,) [closed]
You’re probably running into a problem with $current_user->id being deprecated since WordPress 2.1. Specifically, I get this notice in the error log: Notice: WP_User->id was called with an argument that is deprecated since version 2.1! Use WP_User->ID instead. in /xxx/xxx/public_html/wordpress/wp-includes/functions.php on line 2923. Use $current_user->ID instead. Or you may be able to use get_current_user_id(): add_action( … Read more
If you hook some functions to the before_sidebar action, they will be executed in your code. Your action is now probably without any function hooked, so it returns nothing. Example: <?php add_action( ‘before_sidebar’, function() { echo ‘Try me!’; }); add_action( ‘before_sidebar’, function() { echo ‘Yep. ‘; }, 1); // this should output “Yep. Try me!” … Read more
publish_post doesn’t work for custom post types, the correct hook (action hook) is publish_{$custom_post_type}. You should use add_action() as this is an action hook. I also tend to make use of the transition_post_status hook which is a much more universal hook as it fires everytime a post’s status is changed regardless. You can use $old_status … Read more
You don’t have to declare the constructor public, just the action hook function. Example: <?php /* Plugin Name: Singleton Action */ class Singleton_Demo { /** * @static $instance Objekt * @access private; */ private static $_instance = NULL; protected function __construct() {} private final function __clone() {} public static function getInstance() { if ( self::$_instance … Read more
After WP 2.3 you have for all status an hook: {$new_status}_{$post->post_type} Alternative you can use ans if for the status on hook save_post; an example for post_type post, you can change this ‘post’ to your post_type or defaults form WP: public function set_status_private($id, $post) { if ( is_object($post) && ‘post’ === $post->post_type && ‘publish’ === … Read more
You are actually closer in your first attempt. My recommendation would be to create a folder called “scripts” in the WP root and put your PHP script files in here as well as your attachment(s). You will then need to declare the full path in your action attribute as the script does not now share … Read more
OK, so your first problem is that $current_user->roles is an array and not a string, so your condition won’t be true 😉 My another concern would be the hook you’re using. Some plugins may use it for other purposes, and killing the script can be harmful. And… there is much better hook for this 😉 … Read more
It is usually easy to find most hooks in documentation or source. It can be much more tricky for hooks that are dynamically generated, like post transitions. Essentially it doesn’t exist in source as specific hook – it is hook that is getting generated dynamically at runtime, depending on variables. do_action(“${old_status}_to_$new_status”, $post); do_action(“${new_status}_$post->post_type”, $post->ID, $post); … Read more
To see if the option ‘rewrite_rules’ was reset – that’s what flush_rewrite_rules() does internally – hook into the option actions and log what happens. The following small plugin does that. It will tell you what code flushed the rewrite rules and how the rules looked before and after the flush. If no flush happened it … Read more