Timezones and timestamp SQL to PHP

Dealing with godaddy mySQL timestamps on a shared server. As of this posting, although Arizona is in the Mountain time zone, it does not participate in the Daylight Savings party. Issue is that godaddy timstamps are “readable” but are in US/Arizona timezone. If the server is on a shared host, the default timezone can NOT be changed.

Here is my solution to the problem of querying a godaddy sql server timestamp:

  1. In your PHP script include the line (add your desired time zone as needed):
  2. In the $sql “SELECT….” statement, use the following:
  3. To display the time in a readable format use “date(‘format’,timestamp)” formula:
    echo date(‘D, M j – g:ia’,timestamp);

Create Post Automatically

This will create a Post using PHP.

     Code SOURCE: https://www.youtube.com/watch?v=bVImxRBKBuc
*/ //set timezone date_default_timezone_set('America/New_York'); //require native WordPress function require_once("wp-load.php"); // Post variables $userID = get_current_user_id(); $leadTitle='Operation Test Post' $leadContent='Hello there. this is the post!'; //ID# automatically assigned to categories. For multiple // categories, separate with a comma $categoryID='28'; //Time variables - Sets time for now so post can be published without delay $timeStamp = date_create(); $postdate = date("Y-m-d H:i:s", $timeStamp); //wordpress Array and Variables for posting $new_post = array( 'guid'=>$postID, 'post_title'=>$leadTitle, 'post_content'=>$leadContent, 'post_status'=>'publish', 'post_date'=>$postdate, 'post_author'=>$userID, 'post_type'=>'post', 'post_category'=>array($categoryID), 'comment_status'=>'open', ); //THIS submits the array data to creat the new post $post_id = wp_insert_post($new_post); //Error Checking if ($post_id){ echo "SUCCESS!"; } else { echo 'OOPS! something failed, please try again!'; } ?>

Disable WordPress Nickname

Place the following code in your function.php file. (Appearance > Editor > Theme Functions – functions.php)

// remove nickname
function prefix_hide_personal_options() {
        if (current_user_can('manage_options')) return false;
<script type="text/javascript">
  jQuery(document).ready(function( $ ){
if (is_admin()) add_action('personal_options', 'prefix_hide_personal_options');

Source: https://premium.wpmudev.org/blog/how-to-restrict-usernames-and-disable-nicknames-in-wordpress/

Why use “if (!function_exists(‘…”

Checking to see if built in WordPress functions exist before calling them is for backward compatibility which IMHO is not needed.

So if you see if ( function_exists( 'register_nav_menus' ) ) the theme author is supporting versions earlier than 3.0.

You still sometimes see
 if ( function_exists( 'dynamic_sidebar' ) ) 
Why? I couldn’t tell you because dynamic_sidebar was introduced in 2.2.

Another reason to use it is to make your theme or plugin pluggable. A pluggable function is one that can be overridden in a child theme or another plugin.

This is done on the definition not the call and you use the ! operator to make sure it doesn’t already exist before you define it.

if ( ! function_exists( 'my_awesome_function' ) ) {
 * My Awesome function is awesome
 * @param array $args
 * @return array
function my_awesome_function( $args ) {
  //function stuff
  return array();

When this is done a child theme or other plugin can override that function with there own.

source: https://wordpress.stackexchange.com/a/111318

WordPress Form Receive (POST)

This is the receiving page for the simple form submit.

This is the code

	if (isset($_POST['firstname']) && $_POST['firstname']){

		echo "<p>First Name: $first_name </p>";
		echo "<p>Last Name: $last_name </p>";
	} else {
		echo "<p> Error: some or all of the fields were not completed.</p>";

WordPress Form Submit (POST)

I can’t explain why this was so difficult, but it kicked my butt for weeks. I needed to create a simple form and then submit to a new page.

This is the simple form:

This is the snippet

// code for the form
	$form_html = '
		<style type="text/css">
			 .label { font-size: 100%;
				     font-size: large;
				     font-family: Arial, Helvetica, sans-serif;
					 text-decoration: underline;
			 .content { margin-left: 60px;
			 		font-size: x-large;
					font-family: Arial, Helvetica, sans-serif;
			 .button {font-size: x-large;
					font-family: Arial, Helvetica, sans-serif;
					position: relative;
  					left: 50%;
  					transform: translateX(-50%); 

		<form method="post" action="/wordpress-form-receive/" >
			 <p class="label">First Name:</p>
  				<input type="text" name="firstname" value="Mickey"><br>
  			<p class="label">Last Name:</p>
  				<input type="text" name="lastname" value="Mouse"><br><br>
		<input type="submit" class="button" value="Submit">
		</form>	';
	echo $form_html;


Quick code that checks to see if current user is logged in. Anything other than “0” is logged in.

//Grab the current user details from WordPress
	$current_user = wp_get_current_user();	
	if ( 0 == $current_user->ID ) {
    	echo 'Sorry.  You need to be logged in to see this information....';