A name for an event that is executed at specific points throughout the WordPress core.

learn more… | top users | synonyms (2)

0
votes
2answers
29 views

How to cancel an action hooked to untrash_post? or any hook

I want to do the following in a plugin: - hook to untrash_postwith a custom function - do some checking inside custom function - cancel actual post restoring (untrashing) I've tried with ...
0
votes
1answer
26 views

Is it possible to completely replace a post with an action/filter?

Currently I am trying to replace the $post global with another dynamically loaded post in the wp action. However, while even in the templates the correct post data shows when outputting $post, the ...
0
votes
1answer
23 views

Custom Form Processing Issue

I have created a form on my wordpress site, a function to process the data located in functions.php, and an action php file. I have tested the processing function and know it works, but I'm having ...
1
vote
0answers
64 views

How to find the hook(s) that make site slow

I am working on a site and it is working fine except one thing that it is very slow. I tried to figure out that which plugin or theme is creating the problem and find out that woocommerce-subscription ...
1
vote
1answer
52 views

Modify custom field input data before creating a new post

I'm try to check input data before it is added to DB. For example: I have a custom post meta named book_isbn in post page. I want to make sure that this variable $_POST['book_isbn'] is valid before ...
0
votes
1answer
46 views

How to stop or remove an action being called inside a function of an extended class

The Problem I am trying to remove an JSON+LD block being added by a WordPress plugin called The Events Calendar. I believe it is being added by the function called: ...
0
votes
2answers
36 views

How to add custom post meta to default blog post?

I have a code which calculates estimated reading time of a blog post (feel free to use it as you wish): function estimated_reading_time( $post ) { $words = str_word_count( strip_tags( ...
0
votes
0answers
15 views

how to init wordpress env from within custom script

I know you can run a php script using the wp-cli command which will init the wp env for you as discussed here Initialize WordPress environment to use in command line script but what I want to do is ...
9
votes
2answers
10k views

Difference between do_action and add_action

This question might be wrong, I am not sure about it. Because I am not clear on this. I know add_action it is used to to hook our function to the specified function. For example ...
9
votes
8answers
3k views

Remove an action from an external Class

I'm trying to do something similar to this question here: remove_action or remove_filter with external classes? I'm trying to remove the <!-- This site is optimized with the Yoast WordPress ...
0
votes
3answers
59 views

Action hook on only publishing post not on editing or updating

Could you please let me know wordpress action hook that must triggered only once when a user create a new custom post. That means if user creates a new post that hook must be triggered but when user ...
2
votes
1answer
503 views

Delete user from frontend

Hi I am working on a frontend admin where a user must be able to delete his account. current_user() is a custom made function of me that retrieves the user meta data. Does anyone know how I can make ...
1
vote
2answers
2k views

WordPress custom form action url

Is there any way to replace standard WordPress comments form action, which usually looks like this: <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" ...
1
vote
0answers
14 views

Building a request processor for multi-page forms, etc using $_GET requests

Good day, What I'm trying to accomplish in a semi-elegant way today is building a multi-step form type thing. Essentially, I'm trying to rewrite the page based on a $_GET request. Like, say, it's ...
15
votes
2answers
8k views

How to get WordPress' hook run sequence?

What is WordPress' hooks execution sequence? I mean, I want to know the order, how add_action hooks are executed, i.e. init wp_head wp_footer after_theme_setup and etc.. I want to know the ...
1
vote
2answers
29 views

schedule event in class oriented plugin

Actions usually support the following (if you are creating your plugin using a class based approach): add_action('admin_notices', array(&$this, 'emailNoticeGUI')); The wp_schedule_event does ...
0
votes
1answer
31 views

Prevent function from triggering again when post in specific category gets another category?

I have created a function to send out an email to authors when there post is added in the popular category for custom post type. IT WORKS but there is 1 major issue. If the post that is in the ...
0
votes
1answer
45 views

Dynamically adding filters

I have a function that I'm trying to get an array in it to use in a callback to dynamically add filters. Here is the function that I need to retrieve the array keys from ( in the $classes variable ): ...
1
vote
1answer
46 views

Redirect to another page if the user is logged in when pressing again the login button on menu bar

So I have this button on the menu : "My account" that lets the user login on the website and as soon they log in they're redirect to their dashboard. What I'm trying to achieve is if he's logged in ...
0
votes
0answers
20 views

How to remove the function hooked to action within a class [duplicate]

I want to remove the function listify_single_job_listing_meta which is hooked in action inside the following class class Listify_WP_Job_Manager_Template extends listify_Integration { public ...
0
votes
1answer
38 views

What problems could happen if I replaced add_filter and add_action with the function calling

I'm new to WordPress, and to learn more about how to build WordPress themes, I'm now analyzing the code of a theme I downloaded and trying to make some changes in it. Two of the built-in functions in ...
1
vote
0answers
28 views

add_action shortcut?

I think in PHP 5.4 or above (don't remember the exact version), instead of writing: function some_function() { } add_action( 'init', 'some_function' ); One can pass an anonymous function: ...
1
vote
1answer
29 views

Get posts from WP_Query and format them on admin_head

I am trying to prepare an array with Custom Post Type posts to populate a select options in TinyMCE. I was thinking to fetch posts, get their IDs and titles and put them all inside $data variable, ...
0
votes
0answers
21 views

How do I get the full details of a registered/enqueued script?

I'm trying to get the details (such as src, in_footer etc) of enqueued/registered scripts. For example: add_action('init', function() { global $wp_scripts; var_dump($wp_scripts->queue); ...
34
votes
4answers
12k views

Passing a parameter to filter and action functions

Is a way to pass my own parameters to the function in add_filter or add_action. For example take a look in the following code: function my_content($content, $my_param) { do something... using ...
1
vote
0answers
42 views

Redux callback action

I'm very new with Redux. I don't know how to show and hide a textarea using switch (without saving). When my switch turns on, the text input displays and when it turns off, the input hides itself. I ...
1
vote
1answer
125 views

WP 4.4.1 allow empty comments via add_action 'pre_comment_on_post'

got a question about allowing empty comments with worpdress v.4.4.1 to achieve this i use the action 'pre_comment_on_post'. in WP 4.3.1 i could do this easily: if (isset($_POST['comment']) ...
1
vote
1answer
97 views

Create a plugin to change the action to which a function is hooked

I have a plugin that hooks a function on to the woocommerce_before_my_account action. I would like instead for the plugin to hook that function to the woocommerce_after_my_account action. If I ...
2
votes
1answer
2k views

Why are you using add_action for shortcode?

I would like to create shortcodes, but some tutorials write about to use add_action: add_action( 'init', 'register_shortcodes'); But I read another tutorial where the author didn't use it, only put ...
0
votes
2answers
2k views

Deregister scripts on unnecessary pages using remove_action

To all would-be close-voters: This question is not a duplicate, because I need to remove all scripts added by plugin using remove_action. In Very stubborn wp_register_script / add_action vs ...
8
votes
1answer
6k views

What is the very earliest action hook you can call?

After the solution to this question was to get a function to launch BEFORE the init action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load ...
6
votes
1answer
222 views

wp_headers vs send_headers. When to use each?

I've seen wp_headers and send_headers both used before for the same thing and I'm wondering how you're suppose to know which one to use and when... On the send_headers codex page there's an example ...
0
votes
1answer
5k views

wp_login action hook not working

I have spent many time looking for a solution to my issue, but in vain. Your help is invaluable. I am creating a simplified badge system. The goal is to increment the number of badges for a user if ...
1
vote
2answers
45 views

Delete database tables on theme uninstall?

How can I execute DB queries when theme installs and delete those tables on theme uninstall?
0
votes
1answer
38 views

How to use the post_updated hook before and after arguments

I want to check if the title of the post has changed and do some stuff if it did. I thought of using the post_updated hook, the codex says "Use this hook whenever you need to compare values before ...
0
votes
0answers
23 views

Get Custom Post Type posts on normal edit-posts and pass to TinyMCE

I am following a tutorial for adding a dropdown list in tinyMCE editor. In the end I would like to have a Select list similar like it is in this image , but populated by post titles from Custom Post ...
0
votes
0answers
18 views

How to add new tab and data in Wordpress Users section

I have to add new tab and new data in wordpress users. Please see the image below. The points tab came from the plugin mycred but i don't know what was used. What I think was it was done using: ...
0
votes
1answer
1k views

wp_trash_post action hook with custom post type

When a 'contact' cpt post is trashed, I need a metakey from another cpt 'act' to be deleted, I have been searching all over which hook I should use but unfortunately the codex action reference page is ...
1
vote
1answer
89 views

Hide posts of a certain category unless logged in

I want to hide posts belonging to a certain category unless logged in. I found some code(attached) in the codex that works great for the loop. But how to ensure the post pages are empty as well? ...
0
votes
1answer
72 views

Add action hook into wp_localize_script

Is it possible to add an action hook via wp_localize_script, so I can position where I want the hook to run in HTML markup that is made in the JavaScript? So something like: $data = array ( ...
-1
votes
1answer
24 views

The acction hook stop working if i move it from plugin file to theme's functions.php file

A bp_includes is buddypress action and hooked on plugins_loaded function remove_bp_docs() { global $wpdb; $current_user = get_current_user_id(); //We are selecting member type before ...
1
vote
2answers
4k views

How to only hook on Single.php after content?

I am currently hooking on the_content() but that goes through the Wordpress loop too. How can I only hook on the Single.php page? Also, is there a way to only look on the first X posts in the ...
3
votes
1answer
5k views

Where is the best place to use add_filter

Should I use the function add_filter In my plugin's init action hook or just the in the main plugin script? Since sometimes I found people is using filter all over the place and if I put in the init ...
0
votes
0answers
45 views

Why a class property becomes empty?

I have a class with a private property/variable named $postID that I can pass successfully (this was tested) to every function within this class except one named handleForm(). When it is passed to ...
0
votes
3answers
63 views

Which action hook should I use to intercept a form upon submission?

I have a form on wordpress page with a POST method. I need to add an extra field to the form after submission but before it is sent to the URL in the action attribute. I was thinking to use an ...
0
votes
0answers
149 views

Custom Message with Order status from WooCommerce Payment Gateway Callback to Order Thank You Page

I would like to pass on the custom message to order-received page in woocommerce. Here how i currently handle the callback from payment gateway if ( isset( $_REQUEST[ 'callback' ] ) { ...
-1
votes
1answer
498 views

Call a function with href

Is there any way to call a function inside plugin with <a href='plugin-function'> tag? I need this to show user details which will not be bound to any action hook.
1
vote
1answer
27 views

Custom post type unintentionally called in every page

A while ago I was following a Tutsplus video tutorial on creating custom post type, and so accordingly I made 2 similar small custom post types for myself. Today I was exploring ways on how can I ...
1
vote
2answers
147 views

add_action and Ajax

I'm developing a plugin and I've started from WPPB and Wordpress 4.3.1. I've named it dogmaweb. I need to submit a form to the plugin via Ajax. The form is created by the plugin itself. In my ...
1
vote
1answer
811 views

Insert new user with form submit 'init' hook

I'm posting a form to insert a new user and hooking my function to 'init'. This code is in my mu-plugins folder. The user gets inserted fine, but the page is not loaded after wards. My form action ...