Questions tagged [actions]
A name for an event that is executed at specific points throughout the WordPress core.
1,425
questions
0
votes
2
answers
404
views
do_action not working in loop
I've been using do_action to generate multiple action hooks in the loop. It seems unlucky for me the do_action not working.
function ltc_generate_input_fields($fields = array()) {
echo "Hello ...
0
votes
1
answer
472
views
How to change lost password email text using custom plugin wordpress?
In wordpress, i want to add one extra parameter(ABC) in lost password link with key (lost password email text).
I have added many hooks.
add_action( 'password_reset', 'password_reset_hook', 10, 2 );
...
0
votes
1
answer
333
views
What's the correct way to add capabilites to user roles?
A third-party plugin adds the capability 'edit_booked_appointments'. I'd like to assign this capability to the already existing user role 'editor'. I created the following function in my child theme:
...
0
votes
1
answer
226
views
How do I dequeue js/css at the last possible moment?
I'm trying to dequeue the font-awesome stylesheet included with the ninja forms plugin (because I manually include the latest FA via a CDN).
I did this:
add_action('wp_enqueue_scripts', function () {...
0
votes
1
answer
93
views
Get original value in save_post action hooka
I'd like to get the original value of the $post on the save_post action. This way I can detect changes, and only do specific actions if the post content/title was changed.
Is this possible?
2
votes
1
answer
2k
views
Unable to programmatically remove product from WooCommerce cart
I'm using WooCommerce. For certain conditions, I'll want to remove a specific product from the cart. I feel like I'm using the correct method of doing this, but for some reason it's not working. Other ...
0
votes
1
answer
26
views
Add back in child theme what the parent theme removed with remove_action
My parent theme removes the emoji fallback script that makes emoji show up as images:
// parent theme's functions.php
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('...
1
vote
1
answer
75
views
Save User Meta Email Address in Lowercase
I'm looking for a way to save all email addresses to user meta as lowercase, ideally without validating and asking the user to change it but instead just saving it as lowercase. I've got as far as the ...
2
votes
1
answer
281
views
How can I add data to a custom column in the Users section of the wordpress backend?
Can anyone help me with adding data to a new User table column that I added?
In the wordpress backend, in the Users section, I added a custom column called "Last Name". Now, I'd like to add last ...
2
votes
1
answer
109
views
Explanation for remove_filter used in the below code [closed]
I am very confused about what the developer has done here. This is inside a class..a filter has been added and then removed, added again. This code results in many errors as well.
add_filter('...
1
vote
0
answers
90
views
How do I use remove_action on an add_action that uses an array?
This is a messy question :) I'm running into a conflict between plugins and need to disable one (WP Bakery) on the front end of certain pages.
I'm looking at multiple questions on how to disable a ...
1
vote
1
answer
465
views
Execute Hook on the footer or header after activating a plugin
I have the following code fraction, but it does not work, I want that after activating a plugin this calls an action on the footer and prints something, but I can't do it, the problem seems that the ...
0
votes
1
answer
580
views
Post Click Redirect to Custom URL instead of Single Post Page
I have a custom post type called "articles". When an article link is clicked, I want to redirect them to custom URL(this URL is saved in the database as custom field) instead of the single page. How ...
1
vote
0
answers
21
views
A method for ordering mixed dates in search result loop (theory only, no actual code)
My issue
Hello,
some time ago:
I had the regular post and the custom evento post types;
the evento post type had a ev_data_out custom field;
the search result loop had to return a list of posts from ...
0
votes
0
answers
322
views
Overriding Plugin function in your child theme
Plugin actions
$this->loader->add_action( 'wp_ajax_woo_amc_get_cart', $plugin_public, 'show_cart_items_html' );
$this->loader->add_action( 'wp_ajax_nopriv_woo_amc_get_cart', $...
1
vote
2
answers
219
views
Pros and cons of actions over shortcodes
I need to output some posts on some pages and I created shortcode:
function show_foo() {
// output stuff
}
add_shortcode( 'foo', 'show_foo' );
and I use it like this in templates:
echo ...
2
votes
0
answers
447
views
Using Nested add_action()
I am new in WordPress.I am learning Plugin Development. Is it possible to use Nested add_action() like below ?
add_action( 'admin_post_addAddress', 'add_new_address' );
function add_new_address(){
...
0
votes
1
answer
65
views
ajax-action.php can't find added action
Dear fellow Wordpress plugin developers,
I'm currently developing a WordPress custom booking plugin. In this plugin, I have added a calendar shortcode, which embeds an Html month calendar on the page....
0
votes
1
answer
100
views
How to Unhook actions/filters in within Class in plugin
I have a business website for vacation home rentals in which the WordPress theme has its own booking system for house bookings only and it has been great!
I also, have Tour/Services (not Houses) also ...
0
votes
0
answers
370
views
Add custom action to the page listing screen
I'm creating functionality that will clone a published page and create a new draft page from the content. I placed an action link alongside the "Edit | Quick Edit | Trash | View" items that appear ...
1
vote
0
answers
471
views
Trying to place a custom field after the total section in the checkout page in woocommerce
This code correctly works but does not place the custom field where I want it. In the add_action I would like to use woocommerce_review_order_after_order_total as the location attribute to place it on ...
0
votes
1
answer
3k
views
login_headertitle is deprecated since version 5.2.0
I have an issue my friends. when I got to default logn page in wordpress, I see this error:
Notice: login_headertitle is deprecated since version 5.2.0! Use login_headertext instead. Usage of the ...
0
votes
1
answer
529
views
Custom query_var to get URL paramater not working
I have a custom Wordpress login and if the user gets to the homepage and is not logged in, they are redirected to the custom login form(I have disabled this for now while I test). What I would like to ...
1
vote
0
answers
27
views
How do I add a custom screen for a custom post type to be called from custom post row action?
I have custom post type called messages where I will store emails and my request is very specific. New post cannot be created and user cannot do anything with it except delete it. I have already added ...
0
votes
1
answer
287
views
Filter get_page_by_path()
Is there a way to filter get_page_by_path()? I am trying to allow duplicate slugs for pages, so that two pages can have the same slug if they have different meta value for a specific meta key. Thanks ...
0
votes
1
answer
902
views
How to add custom checkout field in user details mail template
I need to add custom field from my checkout page to email templates.
I already added custom input at checkout page and it shows up in mails but it shows up after products table and I would like it to ...
0
votes
0
answers
197
views
Insert post without actions/hooks
I am developing a custom importer for WordPress (because we have a very custom setup and the available tools don't seem to work for our scenario).
During this import, I'd like to disable any hooks ...
0
votes
0
answers
41
views
Post is uncatagorized in publish_post action
I've added several bits of metadata to my post categories. When that post is published I want to copy some of those meta values into the custom fields of that post.
add_action('publish_post','...
0
votes
0
answers
259
views
do_action doesn't trigger if it's in a template that gets loaded via REST endpoint
i'm building a single page application using woocommerce and custom REST endpoints to get template parts and load them into the browser ... one endpoint is getting content-single-product.php template ...
0
votes
1
answer
415
views
Get_term_meta() does not work with pre_get_posts()
I am trying to get custom term meta value for a certain category using get_term_meta() function. This value is stored in the wp_termmeta table. Then, based on that value, I want to modify the main ...
1
vote
1
answer
149
views
Custom post type suppress transition from future to publish
I've scheduled a custom post type to a future datetime. Now I won't that it will be published automatically, instead it should switch the status to draft.
We use this to pulish the webinars, so we ...
0
votes
0
answers
336
views
WPML - Hook when language is switched (change user language)
I would like to change the logged in user's language (if someone is logged in) when they change the language in front-end.
I'm using the WPML Multilingual CMS plugin in my Wordpress website.
I've ...
1
vote
1
answer
897
views
Wordpress action admin_post for non-admin authenticated users - Form submission
I'm trying to submit form using:
`admin_post` && `admin_post_nopriv`
actions.
This is a shortcode for users search:
add_shortcode( 'search_users', 'search_users' );
function search_users( $...
0
votes
1
answer
1k
views
Is it possible to apply_filter on a wp_ajax_ action?
I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an apply_filters .... (if possible)
Their plugin works with Ajax calls on plugin page admin, so when I ...
0
votes
0
answers
709
views
Nested Actions and Filters
It is possible and a good practice to combine filters and actions, it is necessary to take into account the order in which they are executed, a graphic example https://images.app.goo.gl/...
1
vote
0
answers
107
views
Unable to change footer using wp_footer action hook
I am learning Wordpress from a book and while learning about how to use action hooks the author gives the below code . I am assuming this would change the footer at the front end .
<?php
...
3
votes
1
answer
445
views
enqueuing React script and hooking its target div fails to load script
I am getting a silent failure on the below code as I try to enqueue a static React.js script and hook its injecting div into the admin_footer. I see the page and my test echo plus the url of the ...
0
votes
1
answer
215
views
add_action with associative array
I am trying to get these parameters from the do_action placed inside body:
do_action( 'custom_action', array( 'product_id' => $product_id , 'outbiddeduser_id' => $outbiddeduser, 'log_id' =>...
1
vote
0
answers
95
views
How to list all WC products by their attributes values?
I wanted to get some advice on how to list all my inventory attributes values. I have this simple code that will output the products as plain text, But instead of the_title(); I want a list of all ...
1
vote
0
answers
33
views
Instantiating classes through add_action and saving them to user_meta data [closed]
In my Wordpress.com site I have a form where users can add relationships of different types (coworkers, friends, etc.) and each relationship type has different fields but similar functionality. I had ...
0
votes
1
answer
65
views
trying to add extra field using hooks
I am trying to add an extra field on the backend menu of
Edit Subscription menu (SUMO Subscription (plugin) -> List of
Subscription -> Edit Subscription)
I am sending you a screenshot for where ...
0
votes
1
answer
3k
views
Use action, filter, or hook to append HTML to WordPress plugin function
I am new to WordPress actions, filters, and hooks, and am wondering if it is possible to use one of the three to append some HTML to a defined plugin function using the theme's functions.php file. The ...
0
votes
1
answer
482
views
How to show only specific category post by user role without plugin and restrict all other cats
I am using basic post for adding posts. 5 categories exist ( cat_A, cat_B, cat_C, cat_D, cat_E). And I have 2 custom user_role for registered visitors that is 'viewer_a' and 'viewer_b'. I need to show ...
0
votes
1
answer
2k
views
Use wc_enqueue_js only on specific pages - nested add_action
In my plugin, I'm trying to add inline script using wc_enqueue_js only on the cart page. The rest of the plugin is also executed only on the cart page.
The code below works fine, but I don't like the ...
0
votes
1
answer
1k
views
Best hook for when a user session ends?
I'm creating a backend feature that calculated user's login sessions during the past 2 weeks.
This is easy enough to do by incrementing a custom user field when the user logs in using wp_login:
...
0
votes
1
answer
50
views
why require - does not load filter
I am using the boilerplate for WordPress plugin : https://wppb.me/
but I don't know if it's because of there coding this is happening.
What I am trying to do is use require and load the below code ...
0
votes
1
answer
105
views
add_action doesn't work for my function
I'm trying to build a function which run when a member is registering on my site.
I am building an extranet using the Simple LDAP login plugin to use my LDAP directory so that users connect on the ...
0
votes
1
answer
2k
views
add_action('init') not work
my code is
add_action('init', 'user_logged_in');
function user_logged_in(){
if( is_user_logged_in() && is_page('login')){
wp_redirect(home_url());
exit;
}
}
the page slug ...
0
votes
1
answer
45
views
Translate are not working for standard admin
I'm developing a plugin which uses strings of the "default" textdomain, but several strings will not shown translated.
My locale language is "de_DE" (german).
I try to access the word "Count", which ...
0
votes
2
answers
614
views
W3TC manual cache flush does not work
My need is to have a .php file that is located in the root folders of all WordPress websites I manage, which can flush all cache of all sites.
Therefore, I created a file "flush-cache.php" in the ...