Generate slug and meta data if meta field is empty

Ok, after a little playtime, here is the answer: add_action(‘save_post’, ‘ocp_jobs_save_details’); function ocp_jobs_save_details(){ global $post; $genref = sanitize_title( dechex( time() ) ); if ( $post->post_type == ‘job’ ) { if ( $_POST[‘ocp_jobs_ref’] ) { $jobs_args = array( ‘ID’ => $post->ID, ‘post_name’ => strtolower( sanitize_title( $_POST[‘ocp_jobs_ref’] ) ) ); $myref = strtoupper( $_POST[‘ocp_jobs_ref’] ); } else{ … Read more

Getting duplicate page when activating my plugin

If no result is found, $wpdb->get_row will return NULL not false https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row You are using add_action(‘init’, ‘gallerypage’); so it runs on every load. You should be using register_activation_hook so that it only runs when the plugin is activated. https://codex.wordpress.org/Function_Reference/register_activation_hook Try using get_page_by_path() to check if the page already exists. Then you won’t need to use … Read more

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