• missveronica

    (@missveronicatv)


    Hi,

    When there is a reference to $wpdb in an Action or Filter, you must add the global $wpdb; before the Action/Filter when using the “Code Snippets” Plugin but it’s not required in PHP when you add the code snippet to the child-theme’s functions.php file.

    Example:
    add_action( "update_option_{$wpdb->prefix}user_roles", 'my_um_role_update_name', 10, 3 );

    Would be nice if this can be fixed in the Plugin to be 100% compatible with using child-theme functions.php file.

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    While it would be possible to bring $wpdb into the code scope every time a snippet is executed, it is best practice to always have this line in the same place where you are using the variable regardless.

    I recommend updating your functions.php code to use this line if you want full interoperability.

Viewing 1 replies (of 1 total)
  • The topic ‘global $wpdb;’ is closed to new replies.