Connect to Ms SQL Server

You have probably figured it out by now, but just in case. I was also asked to pull data from an MS SQL server and present the data on a WordPress site. In my plugin, I stored the connection values (encrypted) as options. Here are the basics. Connection Function: public function rimsdb() { global $rimsdb; … Read more

Publish page remotely

Pat is correct the REST API is the best way to add a new post/page to your site. Here is a more complete guide with an example: https://rudrastyh.com/wordpress/rest-api-create-delete-posts.html#create_post Example code for publishing a new post: $api_response = wp_remote_post( ‘https://WEBSITE/wp-json/wp/v2/posts’, array( ‘headers’ => array( ‘Authorization’ => ‘Basic ‘ . base64_encode( ‘LOGIN:PASSWORD’ ) ), ‘body’ => array( … Read more

Maintain user profile data in a non-WordPress database

You can use the WPDB class to instantiate an external DB. Looks like roughly this: define(‘EXT_DB_USER’, ‘username’); define(‘EXT_DB_PASSWORD’, ‘password’); define(‘EXT_DB_NAME’, ‘ext_data’ ); define(‘EXT_DB_HOST’, ‘123.123.123.123:3307′); $wpdb_ext = new wpdb(EXT_DB_USER, EXT_DB_PASSWORD, EXT_DB_NAME, EXT_DB_HOST); then you just call $wpdb_ext with normal WP functions just like you would #wpdb. For log in info it’s usually easiest to sync login … Read more

WordPress with php5-fpm and nginx

Ah, my problem ended up stemming from an issue with php5-fpm. Essentially, there were php5-fpm services running that were “old” and thus when I tried to access mysql from the web, it wasn’t detected. But when I tried to access it via cli, it was detected. That narrowed it down to php5-fpm for me, and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)