Articles of hooks

Remove genesis_404 hook from genesis_loop

I am using the genesis theme and I want to make a custom 404 page. For that, I wish to remove the default 404 hook and implement my own. In my plugins functions.php I added my action: add_action( ‘genesis_loop’, ‘genesis_customizations_404’ ); And in the function I added the remove: function genesis_customizations_404() { echo ‘test’; remove_action(‘genesis_loop’, […]

This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?

This code right here is in my functions.php file and was written to change the text in the media upload button, since I’m using the media uploader to allow site users to upload a personal business card if they choose. When I realized I’d actually like to hide several page elements in the WP uploader, […]

wp_loaded with static Singleton

In my WordPress site, I created a Singleton inside a custom plugin I have, like this: class VBWpdb { private $trace = array(); public static function get_instance() { static $instance = null; if(null === $instance) { $instance = new static(); } return $instance; } //… So, I’m using VBWpdb::get_instance() in a lot of places of […]

What hook do I use if I want to update a user profile field when a new user is created?

What hook do I use if I want to update a user profile field when a new user is created? function default_followers() { // set default follower $current_id = get_current_user_id(); $key = ‘followers’; $value = ‘1’; update_user_meta( $current_id, $key, $value); } add_action(‘????????????????’, ‘default_followers’ ); Ive tried: personal_options_update Ive tried: edit_user_profile_update Neither seem to work.

display available size on hover, in woocommerce shop page

I am customizing the Woocommerce Storefront theme. In the product-list pages (category page, shop page), I would like to display the available sizes of the product when the user hover with its mouse on the image of a product. So I need to add html/php code that will display this on hover: Available sizes: S, […]

WordPress: Add custom add_filter for custom functions

I am coping with the scenario where I need to filter content of my custom function. My function is used for sending emails but I need to filter it just like wp_mail hook do. Here is my function: function koku_crm_send_sendgrid($sendgrid_api_key, $to, $subject, $text, $html) { $sendgrid = new \SendGrid($sendgrid_api_key); $mail = new KCSendGrid\Mail(); $from = […]

Remove tags without a specific meta key from “choose from the most used tags”

I’m trying to only show the tags that are associated to the currently logged in author; I’ve got this 99% working, but the author can still choose tags associated to other users via the “Choose from the most used tags” link. How can I edit this to exclude any tags whose meta tag “author” does […]

Adding function to child theme's function.php

I am trying to do some edits to my parent theme. I have made a child theme so that updating the parent wont cause a problem.Now I want to add a certain function that is in the parent theme’s functions.php to the functions.php file of the child theme. I am using Oblique theme. Here is […]

Send an e-mail notification to custom user role when a file is uploaded to uploads folder

I have written a custom php that allows a user from my templated page from the front end to upload files in a newly created subfolder which takes user_login as its name within the uploads folder. So the root folder is uploads and inside the user’s subfolder are stored all the files. This is my […]

profile_update hook doesn't works inside a class

When I try to use profile_update hook inside a class the callback function is not called. public function __construct() { add_action(‘profile_update’, array( $this, ‘user_profile_update’, 10, 2) ); } function user_profile_update( $user_id, $old_user_data ) { die(var_dump($old_user_data)); } Outside the class the callback function works correctly.