[wp-hackers] Access custom table using global wpdb not working

Chris Hearn chris.hearn01 at ntlworld.com
Wed Jan 11 12:43:09 UTC 2017


Thanks Claudio!

Chris


On 11/01/2017 06:41, Claudio Simeone wrote:
> 2016-12-27 19:17 GMT+01:00 Chris Hearn <chris.hearn01 at ntlworld.com>:
>
> [cut]
>
>> If there some change that only allows "standard" wordpress table names now?
> Hi Chris, to add custom tables in the $wpdb object I did in this way
>
> add_action( 'init', 'register_custom_table', 1 );
> add_action( 'switch_blog', 'register_custom_table' ); // for multisite
>
> function register_custom_table() {
>      global $wpdb;
>      $wpdb->custom_tablename = $wpdb->prefix . 'custom_tablename';
> }
>
>
> regards
> Claudio
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


More information about the wp-hackers mailing list