Call to undefined function get_userdata in user.php

My website error log is full of [lsapi:error] [...] Backend fatal error: PHP Fatal error: Call to undefined function get_userdata() in /home/.../public_html/wp-includes/user.php on line 460 ... and the site does not load (blank page, no source). The only changes that were recently made are Wordpress and plugin updates (I don't know which ones and when); no programming of any kind. This answer made me suspect that a plugin did override get_userdata, but a recursive search for function get_userdata in the …
Category: Web

Disable email notification after change of password

I want to disable the email notification if a user or an admin changes the password of a user. After some Googling I came to find that I need to create a plugin and overwrite the wp_password_change_notification function found in pluggable.php. This is the plugin and function: <?php /* Plugin Name: Stop email change password Description: Whatever */ if ( !function_exists( 'wp_password_change_notification' ) ) { function wp_password_change_notification() {} } ?> I uploaded the file to my plugin folder and activated …
Category: Web

RSS feeds for specific topics

on a word press site i am trying to build, i am trying to get a listing of current news feeds from reliable sourced on a specific topic. In the WordPress RSS options, is there a way to set up a feed, and have it only pull news articles with a specific key word? if so, where do i go to set that up? If not is there a script or a plugin that can be used to have a …
Category: Web

Override a function defined in wp-includes/comment-template.php

I need to override the function get_cancel_comment_reply_link or cancel_comment_reply_link that are defined in wp-includes/comment-template.php These functions are not listed in pluggable.php. How can I override them from my theme's functions.php? I tried remove_filter('get_cancel_comment_reply_link', 'cancel_comment_reply_link'); add_filter('get_cancel_comment_reply_link', function($text='') { return ''; }, 1, 1); without success.
Category: Web

How to apply a function to the value $email of get_user_by to override email_exists?

More precisely questions : How to override email_exists via get_user_by ? I have chosen to render unusable/unreadable email adresses from database. I added a few elements(chars) to email address just after sending email to admin and user (user registration), and then I must remove these added elements to verify if email exists or display on user account or use for mailing list. To decrypt the email I must use substr whith the value associated to $email field of get_user_by to …
Category: Web

Login cookies blocked after customizing hashing method

I get the following error when trying to login: Error: Cookies are blocked due to unexpected output. I customized the wordpress core functions wp_hash_password() and wp_check_password() to use SHA1 algorithm for user authentification instead of MD5. I modified them in the pluggable.php file (not best practice but good for testing). The functions now look like this: function wp_hash_password( $password ) { global $wp_hasher; if ( empty( $wp_hasher ) ) { $wp_hasher = sha1( $password ); } return $wp_hasher->HashPassword( trim( $password …
Category: Web

Need to replace Currency Shortforms

I want to replace the currency shorten alphabet, it is currently in M, L and So on. I want to change to indian currency number format like K, L and CR below is code: if(!function_exists('houzez_number_shorten')) { function houzez_number_shorten($number, $precision = 0, $divisors = null) { $number = houzez_clean_price_20($number); if (!isset($divisors)) { $divisors = array( pow(1000, 0) => '', // 1000^0 == 1 pow(1000, 1) => 'K', // Thousand pow(1000, 2) => 'M', // Million pow(1000, 3) => 'B', // Billion …
Category: Web

How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?

The current result is "PHP Fatal error: Call to undefined function wp_get_current_user()" which makes sense, but doesn't help. I need to use $current_user. Here is the code I'm currently using: $wp->init(); do_action( 'init' ); // Check site status $file='http://xxxxxxxx.com/wp-admin/wp_includes/pluggable.php'; if ( is_multisite() ) { if ( true !== ( $file = ms_site_check() ) ) { require( $file ); die(); } unset($file); } // Get the current user's info $current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) ) return; echo $current_user->user_login; …
Category: Web

Is it possible to override only a part of another plugin's / theme's js (asset) file?

I try to go one step forward based on this question and instead of overriding the whole .js file of another plugin, i'm wondering is it possible to override/swap only a part of that js file dynamically? To somehow maybe 'inject'/ import my own function(s) additionally into that specific file safely (and fairly natively:)?
Category: Web

Postman: wp_mail has been declared by another plugin or theme

I need use Postman for sending email using an SMTP server, but when installed, it shows this message: Postman: wp_mail has been declared by another plugin or theme, so you won't be able to use Postman until the conflict is resolved. I've uninstalled all unnecessary plugins; but it still does not work. Searching all files for wp_mail() and the other plugins that use wp_mail() are: ./wp-content/plugins/nextgen-gallery/freemius/includes/class-freemius.php ./wp-content/plugins/planso-forms/includes/submit_notifications.php I need these plugins and I don't understand how to resolve this issue. …
Category: Web

the file placed in the child theme is not included

I have modified the theme.php file located in the parent theme in the "Includes" folder, and I have placed it in the child theme also in the "Includes" folder, but my changes are not included. WordPress only reads the file placed in the parent theme folder. What is the reason for this? What should I do the modifications are included when the file is located in the child theme folder? Alternatively, how can I override a function from includes/theme.php in …
Category: Web

How to target post and pages and not all post types in admin?

I've got a strange issue with a plugin I'm modifying. What happens is that this plugin adds meta boxes in an dashboard options page so scripts and style sheets can be globally added to the header and footer areas of a site via wp_footer() andwp_header()`. This plugin also adds one meta box to each page and post editor, and I think that's where the problem is; it also adds meta boxes to other plugin admin panels, which of course I …
Category: Web

Best collection of code for your 'functions.php' file

As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my WordPress skills. Over the past 12 months I have been on a mission to substitute my use of plugins by adding code to my functions.php file instead. While I completely agree that plugins are very useful in many situations, my experience proved that in 90% of usage cases although a plugin might exist, actually utilizing …
Category: Web

How to execute init or woocommerce_init only for checkout page

I am making extra function for my own project. function devsol_customer_login() { if ( is_checkout() ) { ?> <form method="post"> <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="username" autocomplete="username" value="<?php echo ( ! empty( $_POST['username'] ) ) ? esc_attr( wp_unslash( $_POST['username'] ) ) : ''; ?>" /> <button type="submit" class="woocommerce-Button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Log in', 'woocommerce' ); ?>"><?php esc_html_e( 'Log in', 'woocommerce' ); ?></button> </form> <?php $user_phone = sanitize_text_field( $_POST['username'] ); if ( $user = get_user_by( 'login', $user_phone) ) …
Category: Web

Override plugin class which has namespace

I would like to override this plugin class in child theme : class-config.php namespace um; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'um\Config' ) ) { /** * Class Config * * Class with global variables for UM * * @package um */ class Config { //some code here... } //end class } But as you can see, this class uses a namespace, so I can't just write this in my functions.php : functions.php class …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.