New answers tagged hooks
0
votes
Redirect customer to login if not logged in when proceeding to checkout
Add the code below to your child's theme functions.php file.
function wp_checkout_login_redirect() {
if ( ! is_user_logged_in()&& (is_cart() || is_checkout() ) ) {
wp_redirect(...
0
votes
Conditionally run function based on custom meta value?
Instead of conditionally adding an add_action() call, you can just add it and run the function it hooks to—its callback—conditionally instead.
For example:
add_action( '...
0
votes
Accepted
Hook before user is created and make some custom validation
You need to add , 10, 3 after your closure to set the hook priority and (more importantly) the number of accepted arguments - otherwise $user_email and $errors will not be passed.
add_action( '...
0
votes
getEntityRecord without knowing the post type
As of today, you can use the following to get the current post type :
import { useSelect } from '@wordpress/data';
const postType = useSelect(
(select) => select('core/editor')....
1
vote
Is there a JavaScript equivalent of get_post_field?
The @wordpress/hooks package only gives you a JS-like equivalent to the PHP-based hook system in WordPress - they are entirely separate, and don't bring any native WP PHP functions to the table.
What ...
2
votes
Accepted
Append a code when at the current page in wp_list_pages()
I would use a custom walker and then extend the Walker_Page::start_el() method, like so:
// Based on Walker_Page for WordPress v6.0
// @link https://github.com/WordPress/wordpress-develop/blob/6.0/src/...
0
votes
Best possible way to get all options
There is a solution to query all the options that can be set by the plugin, if these are registered settings.
I assume you register the settings as follows:
register_setting( 'plugin-settings-group', '...
1
vote
How to remove js ui library added by default by wordpress
The related library is registered with a function called wp_default_scripts.
File location (for Wordpress 6.0): ...wp-includes/script-loader.php
remove to remove the relevant script; The add function ...
3
votes
Accepted
What is the "correct" way to add hooks or similar PHP behavior to a blocktheme?
I'm not the most experienced in block themes, but from what I've seen of them so far I feel pretty confident in saying that the functionality you describe should be implemented as a block. But it's ...
0
votes
Restrict editing of post type to list stored in user meta
Ideally access controls would be implemented via WordPress's Roles and Capabilities system. But in highly-granular cases such as limiting access to a single post to a few users, the map_meta_cap ...
Top 50 recent answers are included
Related Tags
hooks × 2213filters × 466
actions × 443
plugins × 286
plugin-development × 281
functions × 236
php × 180
woocommerce-offtopic × 167
custom-post-types × 100
customization × 85
posts × 81
theme-development × 71
ajax × 56
admin × 52
wp-admin × 51
custom-field × 44
javascript × 43
login × 40
block-editor × 38
user-registration × 37
menus × 36
themes × 36
templates × 35
wp-query × 34
images × 34