Get current user id in function php

You’re running your code on the wp_loguout hook, which is after the user has logged out, so of course there’s no current user ID. There’s no current user at all. If you look at the documentation for the wp_logout hook, you will see that the ID of the user that was logged out is passed … Read more

Dropdown Category form. Only show Sub-Categories

You just need to set the parent argument of get_categories() (or better yet, get_terms() to the ID of the the-building-code term. If you don’t know the ID you’ll need to retrieve that first: <form class=”js-filter-form”> <select name=”categories” id=”categories”> <?php $parent = get_term_by( ‘slug’, ‘the-building-code’, ‘podcast_category’ ); $cat_args = array( ‘taxonomy’ => ‘podcast_category’, ‘parent’ => $parent->term_id, … Read more

Run a sql (update) after 12 hours after the user login. Woocommerce users

You could do something like this (this code has not been testedt). function schedule_sql_command($user_login, $user) { // 12 hours in seconds. $from_now = 12 * 60 * 60; // schedule a call to a custom hook passing in the user’s ID wp_schedule_single_event(time() + $from_now, ‘run_sql_command’, array( $user->ID) ); } // this is the custom hook … Read more

Show a specific post in wordpress with links

They’re not clickable because that output doesn’t include any of the post permalinks. You can try this: By <?php the_author_posts_link(); ?> on <?php the_time(‘F jS, Y’); ?> in <?php the_category(‘, ‘); ?> <?php $post_id = 1; $queried_post = get_post($post_id); ?> <h2><a href=”<?php echo esc_url( get_permalink( $post_id ) ); ?>”><?php echo $queried_post->post_title; ?></a></h2> <?php echo $queried_post->post_content; … Read more