Tag Info

New answers tagged

0

I believe you can get the same result what you are looking for with filter hook post_updated_messages. You just need the post id for the confirmation thing that you are doing which you can do over here as well using $_GET['post'] which contains your post id. Here is function which will do the thing. function your_modified_message( $messages ){ ...


0

I have changed the do_action() for a apply_filter(). This worked as follows: // Filter save settings $settings = apply_filters( 'gtp_theme_settings_tab_save', $settings, $tab, $_POST ); $updated = update_option( 'gtp_theme_settings', $settings ); And then my add_filter in plugin file looks like: function ac_theme_settings_tab_save( $settings, $tab, ...


3

wp_loaded is called long, long before the post content is fetched. Put that code into a plugin. Also, you shouldn't echo anything that early. The HTTP headers aren't sent yet on wp_loaded, so you will get the Headers already sent error, and your user authentication will not work: you cannot log in anymore.


0

if you create your own hook, here is example. // lets say we have three parameters [ https://codex.wordpress.org/Function_Reference/add_filter ] add_filter( 'filter_name', 'my_func', 10, 3 ); my_func( $first, $second, $third ) { // code } then implement hook: // [ https://codex.wordpress.org/Function_Reference/apply_filters ] echo apply_filters( ...


2

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 ;) First solution: using login_redirect hook function ...


1

For mee it seems that the template_redirect hook worked. Thanks to Pieter Goosen. Heres a solution that should work on earlier hooks: function gdymc_object_exists( $object_id ) { return ( get_the_title( $object_id ) ) ? true : false; } function gdymc_objectID() { if( is_numeric( $_GET['page_id'] ) ): $object_id = $_GET['page_id']; ...


0

This may not be the exact answer to the problem. But it helped me to solved the very problem we are discussing. As using 'transport' => 'postMessage', I was not able to see previews lively. So I created new files using the following code at Github I just copy pasted this code. Verified it and then tweaked it according to my requirements. I know this is ...


3

There is a dynamic hook right before any new metadata is added: do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value ); It would be add_post_meta for posts accordingly. Note that you might to tinker some to catch this precisely in the case of new post being created, for example hook into publish_post first, note the ID, and add to this ...


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


0

Based on the comments of @Milo and using the rewrite analyzer plugin I found what I understand as a conflict in the rewrite rules?. The following url: exams/high-school/city-name/subject/math/ matches the following rules Pattern: (.?.+?)/page/?([0-9]{1,})/?$ Subtitution: pagename: exams/high-school/city-name/subject/math paged: 1 Pattern: ...


1

Method 1 is much more robust and extendable, in my opinion. The main reason is that to add or remove forms, with Method 1 you just add or remove a function rather than modify an existing one, as in Method 2. a) Thus, with Method 1 you can add or remove functionality from other files, in particular from separate modules of your plugin or other external ...


0

What about using save_post or wp_insert_post hook, both have @param     int               $post_ID     Post ID. @param     WP_Post     $post          Post object. @param ...


4

The name of the current hook is always current_filter(). Despite its name, this function returns the name of actions too. Usage example: Move the textarea in a comment form. The current priority is: key( $GLOBALS['wp_filter'][ $hook ] ).


0

Also look at the upgrader_post_install hook. It's at the end of the install_package function, see also the rather bland WP developer page on this hook -- but of course you'll want to run tests yourself to ensure this hook indeed fires when WP core, any plugin, or any theme is upgraded. In general, I'm finding Adam Brown's WP hooks database the most ...



Top 50 recent answers are included