Override WordPress core functions via the plugin

Advertisement

WordPress allows us to override some functions from the plugin.

We can define those functions into the plugin and implement our own logic.

File: wp-includes\pluggable.php

Below is the list of all WordPress core functions which we can override from the plugin.

  • wp_set_current_user( $id, $name = ” )
  • wp_get_current_user()
  • get_userdata( $user_id )
  • get_user_by( $field, $value )
  • cache_users( $user_ids )
  • wp_mail( $to, $subject, $message, $headers = ”, $attachments = array() )
  • wp_authenticate( $username, $password )
  • wp_logout()
  • wp_validate_auth_cookie( $cookie = ”, $scheme = ” )
  • wp_generate_auth_cookie( $user_id, $expiration, $scheme = ‘auth’, $token = ” )
  • wp_parse_auth_cookie( $cookie = ”, $scheme = ” )
  • wp_set_auth_cookie( $user_id, $remember = false, $secure = ”, $token = ” )
  • wp_clear_auth_cookie()
  • is_user_logged_in()
  • auth_redirect()
  • check_admin_referer( $action = -1, $query_arg = ‘_wpnonce’ )
  • check_ajax_referer( $action = -1, $query_arg = false, $die = true )
  • wp_redirect( $location, $status = 302, $x_redirect_by = ‘WordPress’ )
  • wp_sanitize_redirect( $location )
  • _wp_sanitize_utf8_in_redirect( $matches )
  • wp_safe_redirect( $location, $status = 302, $x_redirect_by = ‘WordPress’ )
  • wp_validate_redirect( $location, $default = ” )
  • wp_notify_postauthor( $comment_id, $deprecated = null )
  • wp_notify_moderator( $comment_id )
  • wp_password_change_notification( $user )
  • wp_new_user_notification( $user_id, $deprecated = null, $notify = ” )
  • wp_nonce_tick()
  • wp_verify_nonce( $nonce, $action = -1 )
  • wp_create_nonce( $action = -1 )
  • wp_salt( $scheme = ‘auth’ )
  • wp_hash( $data, $scheme = ‘auth’ )
  • wp_hash_password( $password )
  • wp_check_password( $password, $hash, $user_id = ” )
  • wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false )
  • wp_rand( $min = 0, $max = 0 )
  • wp_set_password( $password, $user_id )
  • get_avatar( $id_or_email, $size = 96, $default = ”, $alt = ”, $args = null )
  • wp_text_diff( $left_string, $right_string, $args = null )
view raw pluggable.md hosted with ❤ by GitHub

Below is the list of those functions which we’ll not override

  • set_current_user($id, $name = ”)
  • get_currentuserinfo()
  • get_userdatabylogin($user_login)
  • get_user_by_email($email)
  • wp_setcookie($username, $password = ”, $already_md5 = false, $home = ”, $siteurl = ”, $remember = false)
  • wp_clearcookie()
  • wp_get_cookie_login()
  • wp_login($username, $password, $deprecated = ”)
%d bloggers like this: