Check User Role ( if statement included )
<?php $user_id = get_current_user_id(); if (!empty($user_id)) { $user = wp_get_current_user(); $role = ( array ) $user->roles; // echo $role[0]; if ($role[0] == 'free-client' OR $role[0] == 'administrator') { //code here... } } ?>
PHP Delete Cookie
<?php // set the expiration date to one hour ago setcookie("user", "", time() - 3600); ?> <?php echo "Cookie 'user' is deleted."; ?>
PHP Set Cookie and Retrieve Cookie
<?php $cookie_name = "user"; $cookie_value = "Alex Porter"; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); ?> <?php if(!isset($_COOKIE[$cookie_name])) { echo "Cookie named '" . $cookie_name . "' is not set!"; } else { echo "Cookie '" . $cookie_name . "' is set!<br>"; echo "Value is: " . $_COOKIE[$cookie_name]; } ?>
WordPress Add Custom Post Type With Category
// Custom Post 1 register_post_type( 'courses', array( 'labels' => array( 'name' => __( 'Courses' ), 'singular_name' => __( 'Course' ) ), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail'), 'show_ui' => true ) ); register_taxonomy('courses_categories', 'courses', ['label' => 'Courses Categories','hierarchical' => true]);
NB! (The hierarchical array item is Important)
,’hierarchical’ => true
WordPress Jquery Not Defined
Add this line of code at the top of your child theme function. It should get rid of your error. If not good luck debugging 🙂
wp_enqueue_script('jquery');
© Garth Baker 2024 All rights reserved.