Hooks a function on to a specific action. Actions are (usually) triggered when the WordPress core calls do_action().
3
votes
1answer
40 views
Which action for triggering cron “wp”or “init”?
Which one do you recommend using within a plugin and why?
add_action( 'wp', 'trigger_me' );
function trigger_me() {
if ( !wp_next_scheduled( 'my_plugin_cron' ) ) {
...
0
votes
1answer
15 views
How to access function from outside of a class within this class in WP plugin?
I am developing a WP plugin called e.g. DD_Awesome_Plugin and this is my code so far (simplified version without additional code logic within class functions):
class DD_Awesome_PLugin {
public ...
0
votes
0answers
10 views
BuddyPress: groups_group_create_complete action does not fire after creating a new group
The action hook groups_group_create_complete does not fire after I created a new group. What could be the problem?
6
votes
1answer
202 views
How to create an API for my plugin?
I have been developing plugins for WordPress. Most plugins I have developed with two three classes and not so huge like Buddypress, WooCommerce or etc.
I am planning to make two open source plugins ...
1
vote
2answers
32 views
Replace a word with a word in the URL string
I'm trying to replace a word on every page for example "Denver" with a word from a URL string, so I'll have like ?city=Atlanta in the URL. So I was thinking of using PHP's GET to just get the city ...
0
votes
0answers
39 views
How to add X number of products to woocommerce cart at once
I am trying to add x number of products input and button to my catalog page so I can select a number, then hit add to cart.
Is it possible to add in this function? The user will provide a number ...
0
votes
1answer
28 views
How to show a users bio on a page
I'm fairly new to Wordpress. I have users that create profiles on my site and one of the sections is their bio. How can I take this information and display it on lets say a "users profile page".
...
1
vote
1answer
50 views
Using several add_action with parameters inside a class
I'm creating a theme framework and using a class to initiate all basic function of the theme (adding theme support, menus, etc). I've got stuck when I tried to enqueue the scripts and styles though:
...
0
votes
2answers
27 views
Problem with executing a function on saving a post
Here is my basic plugin code. I am just starting from scratch. I will explain the functionality. It is simple, While my plugin is active it will add a new meta box in add new post page just below the ...
1
vote
0answers
59 views
Filter list by a unique meta value dilemma
I'm been racking my head at this for a while now, and I can't figure out how to fix the code.
Here's the issue;
I found a snippet of code online to filter my post results in edit.php based on ...
-1
votes
1answer
25 views
What do the numbers mean at the end of add_action('save_post')…?
I've seen on a few tutorials that there are numbers at the end of the call to save Custom Fields/Meta Boxes on the save_post hook. For example, in the WordPress Codex it gives the following example:
...
0
votes
1answer
32 views
How to do a task only once for logged in users
I want to do a task only once after an user has visited my site. I am currently doing like this:
function my_task(){
//do my tasks
}
add_action('init', 'my_task');
I am doing this from a ...
0
votes
1answer
22 views
Is there an action for save_menu and/or update_menu?
I want to "save" my menus into transients. I want to update those when there's been any changes to the menus via the admin custom menus. I've looked for an action but can't see to find anything. ...
0
votes
1answer
62 views
add_action on a specific page
I found this script Wordpress Media Manager 3.5 - default link to
and it works fine for me. But my problem is, that I have a custom wp_editor on the front end where I want it to work, but I can't ...
0
votes
0answers
37 views
do_action in index.php and add_action in functions.php not displaying anything [closed]
I'm trying to display in my index.php a div created by a add_function in my functions.php
So in my functions.php I have:
function display_special_banner(){
echo '<div>Ciao</div>';
}
...
1
vote
1answer
84 views
Why are you using add_action for shortcode?
I would like to create shortcodes, some tutorials write about to use add_action
add_action( 'init', 'register_shortcodes');
but I read tutorials where the author didn't use it, only put
...
0
votes
2answers
53 views
Display Something in the Header After All Styles are Loaded
I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a <style> in the header after ALL ...
1
vote
1answer
53 views
Detect type of post status transition
I have a function on my site that it supposed to run when a new post is published (email push notification), with the exception of the same article updated (i.e publish_to_publish transition, I don't ...
0
votes
1answer
34 views
How to get current action?
I am developing custom registration form. Is it possible to get current action (comment adding or user registration) in function? For example i am using:
add_filter('preprocess_comment', ...
1
vote
2answers
102 views
remove_action in a theme
I'm using a theme that gets updated pretty frequently. For this, it has added a custom.php file to include modifications. Now, in this theme, under the functions.php, the developer has included his ...
1
vote
0answers
49 views
add_action on inherit post status
I'm trying to use the add_action() hook to run a custom function, but am struggling with the post status.
I originally tried using:
add_action('pending_to_publish_portfolio', 'my_function');
...
-1
votes
1answer
530 views
WooCommerce Order Status Displays Twice on Order Page
I modified the woocommerce_custom_order_columns function to make some changes to the WooCommerce Admin Order page. Everything works great, except that Order Status shows up twice (but only for the ...
0
votes
0answers
22 views
How to pass CLASS function with arguments to add_action? [duplicate]
Possible Duplicate:
Passing a parameter to filter and action functions
This works:
add_action('hook', array($this, 'someFunction'))
These not:
add_action('hook', array($this, ...
0
votes
1answer
82 views
Would there be anything stopping me from removing both wp_head and wp_footer?
Some plugins rely on either wp_head or wp_footer or both to introduce their own stylesheets and JavaScript. Those scripts take time to load and slow down my website. Therefore, I would like manually ...
3
votes
2answers
78 views
How do I use add_action from a class method?
For some context, we're building an activation system for new users of an app using WordPress as a framework. We've got a plugin driving most of our interactions, where all of this code resides.
When ...
1
vote
2answers
60 views
admin-ajax.php “ Missing argument 2” warning
I have the following code in functions.php
<script type="text/javascript">
var post_id = "1055"; // hardcoded post id for testing purposes
var type = "some_type";
var data = {action: ...
2
votes
1answer
43 views
Perform action on WPMU blog deletion
Hi guys :) I know there is the wpmu_new_blog action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action ...
0
votes
1answer
84 views
How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
Info about wp_die from codex: Kill WordPress execution and display HTML message with error message. A call to this function complements the die() PHP function. The difference is that HTML will be ...
0
votes
1answer
78 views
where does my function output from load-* go?
I've got a function hooked into load-edit.php that prints out print content:
add_action('load-edit.php', array($this, 'generate_bulk_print_content'));
public function generate_bulk_print_content() {
...
1
vote
1answer
73 views
Implement Hooks Using Array
I'm trying to implement some hooks into a theme, but rather than write out every hook with repetitive code I was wondering if I could use and array to declare the hooks instead.
E.g. ordinarily i'd ...
1
vote
1answer
124 views
Action hook load_textdomain $domain variable
I use the load_textdomain action hook to list all active localization text domains with corresponding path to translation files.
function mo_location( $domain, $mofile ) {
if ( ...
0
votes
1answer
160 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 ...
2
votes
1answer
293 views
Trigger custom action when setting button pressed
This is my first wordpress plugin and I'm running a lot of trouble making it work, it almost work fine but I don't find a way to accomplish this specific thing.
Basically I've my custom setting page ...
1
vote
1answer
103 views
Convert hyphen to underscore in permalinks
I would like to use underscore in my permalinks instead of hyphen.
Current permalink:
www.example.com/2013/01/hello-this-is-a-test-post/
Desired permalink
...
2
votes
1answer
48 views
Is it possible to use object in add_action?
So is it possible to do something like this with add_action?
class class{}
$my_class = new class;
add_action('init', 'my_class');
3
votes
2answers
56 views
How to count number of functions attached to an action hook?
I have some actions like this
function simple_notification() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification' );
...
0
votes
1answer
36 views
Modify functions.php to add a term 'uses-theme' set to theme name on post save
I need to automatically (without anything visible to the user in the UI and without user intervention) 'mark' a post in a sub-blog with the theme it was set to when the user posted.
As I understand ...
0
votes
1answer
48 views
Can admin_bar_menu or another action be used to modify the admin bar on the admin side?
I have used add_action('admin_bar_menu', 'modify_admin_bar') to change the admin bar on the "front end" of WordPress (the site the user sees). However, it seems that modify_admin_bar() is not called ...
1
vote
3answers
280 views
Custom post type save_post action not firing
Sorry if this is already answered on here. I looked around and couldn't see any answers to my question so I thought I'd post my own.
I'm building a plugin for a client that gathers customer feedback ...
0
votes
2answers
82 views
Trying to get custom js files in my admin header
I'm trying to add a java script file to my admin header and use admin-ajax.php to use ajax in my wp-admin (still learning a lot about the process). I've created a custom folder in my ...
0
votes
1answer
124 views
Dynamic wp_enqueue_scripts?
Is it possible to call wp_enqueue_scripts dynamically?
For example, I want to use in function.php my own function
addThemeJS( true, 'modernizr', THEME_JS_DIR . "/plugins/modernizr.custom.js", ...
0
votes
1answer
52 views
Call do_action class's function
There is the following do_action
else
do_action( 'example', $this->nothing());
Where nothing() does exactly what it sounds like.
This logic is in a public function testFunction in a class ...
0
votes
1answer
40 views
How to get the group_id from the “groups_join_group” action in buddypress
I want to get the GROUP_creator_id when an user joins any GROUP. So if I got the group_id after immediately performing the the groups_join_group action by add_action() method.
0
votes
1answer
117 views
frontend show edit profile with selected custom options
So I have many custom user profile fields.
When I use do_action( 'show_user_profile', $profileuser ); hook it displays all custom user profile fields..
But I would like to show only certain fields. ...
0
votes
3answers
161 views
Using get_terms for custom taxonomy in functions.php
I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel.
function retrieve_my_terms() {
global $terms;
$terms = get_terms('taxonomy');
foreach ...
1
vote
2answers
298 views
Check if action hook exists before adding actions to it
I am trying to add a rel=next and rel=prev link tags to the head element of image.php template file. I have Wordpress SEO installed and I like to hook to this plugin wpseo_head action hook to achieve ...
0
votes
1answer
69 views
function to return comma separated list of meta values
I'm customizing the admin edit.php screen and I have a column that displays a meta key $gear. But it only lists the first value instead of returning a list of all the values. Here's the bit that ...
0
votes
1answer
195 views
Displaying custom taxonomy in the admin list of a custom post type
I'm trying to list the terms of a custom taxonomy ('genre') in the overview table in the admin area for a custom post type ('station'). To get this, I tried the following code in my theme's ...
0
votes
2answers
111 views
Auto-Tweet if Type is 'Status' using OAuth
Should be simple - I'd like WP to tweet the content of a post once (when it's published the first time) if the post format is 'status'.
The code below isn't returning an error on publish, nor is it ...
2
votes
5answers
236 views
How do I make a theme “plugin-ready”?
How do I revise a theme so that I can publish my event hooks and anyone can build a plugin to add new functionality easily to my theme?