Linked Questions

4 votes
2 answers
11k views

How to pass a parameter to this add_filter example [duplicate]

I have a class with this function to provide a user language based on $user_id function provide_user_language($user_id) { return apply_filters('get_user_language',$user_id); } So in my script, I ...
Emerson Maningo's user avatar
3 votes
2 answers
10k views

How to pass arguments to add_action() [duplicate]

I declared an action for a single event in Wordpress which accepts an array as an argument: $asins = array(); //I had to declare this since I'm getting a notice of undefined variable if I don't ...
soul's user avatar
  • 371
0 votes
1 answer
2k views

How to create Admin Notice from Plugin with argument? [duplicate]

I'm coding a custom plugin to perform some actions at specific times. I'm playing with add_action and add_filter but the current task I'm working on is posting the post url to Twitter account. Problem,...
corentino's user avatar
0 votes
1 answer
2k views

How to pass variables to a function argument using add_action [duplicate]

I have a test.php plugin file inside my plugin/ folder and I am trying to send an email from this plugin. I have a code that looks like this currently in my plugin. add_action('init', '...
meskerem's user avatar
  • 101
0 votes
0 answers
120 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 ...
terminator's user avatar
12 votes
3 answers
25k views

How to Pass External Variables to Filters/Actions

I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around. Take this example: $...
kingkool68's user avatar
  • 1,219
0 votes
2 answers
5k views

Using dynamic conditions in 'posts_where' filter

I have the following code which gives be posts that are published in the last 100 days function smbd_cats_by_days ($where = '') { $where .= " AND post_date < '" . date('y-m-d', strtotime("-...
Sudar's user avatar
  • 809
1 vote
3 answers
2k views

the_excerpt - want to modify password protected output

I'm looking to modify the output of the_excerpt when there isn't an excerpt specified and the post is password protected. I already can modify the password protected form to whatever I want, but ...
cmegown's user avatar
  • 773
0 votes
2 answers
3k views

How to pass hook variable to function?

I have a function that has an add_action inside it that calls the user_register hook. I would like to be able to echo the variable $user_id from the user_register hook and the $_POST array as well. (...
neanderslob's user avatar
0 votes
1 answer
2k views

Why won't the action hook wp_head accept parameters?

I'm working on a plugin that adds scripting to the head using add_action('wp_head',..); I have to pass a variable to the function to get my desired result. To test this I'm simple "echoing" out the ...
dcp3450's user avatar
  • 455
0 votes
2 answers
2k views

Can I pass parameters to the add_shortcode() function?

As the title states, I need to pass at least one parameter, maybe more, to the add_shortcode() function. In other words, those parameters I am passing will be used in the callback function of ...
Greeso's user avatar
  • 2,166
0 votes
1 answer
331 views

Add Filter - Pass Variable (PHP < 5.3)

When using Anonymous Functions in PHP < 5.3 I get this error: Parse error: syntax error, unexpected T_FUNCTION This is especially troublesome for add_filters. For instance, if I want to make a ...
Howdy_McGee's user avatar
  • 20.6k
0 votes
3 answers
74 views

Sending Parameter Failed

This is so basic, but i couldn't understand why it's not working, i'm trying to send parameter from add_action(), this is my code in my function.php: function testingID( $testParam) { var_dump($...
Viktor Iwan's user avatar