Skip to content

WordPress shortcode to display user registration date

    If your site offers the possibility for users to register, you might at some point want to be able to display users’ registration date. Here’s a super simple code snippet to create a WordPress shortcode that will display registration date of a specific user. First, place the code below into your theme’s functions.php file and don’t forget to save. function wpb_user_registration_date($atts, $content = null ) { $userlogin = shortcode_atts( array( ‘user’ => FALSE, ), $atts ); $uname = $userlogin[‘user’]; if… Read More »WordPress shortcode to display user registration date

    WordPress tip: How to display a disclaimer on posts older than one year

      When you’re blogging, it can be a good idea to display a warning to your visitors stating that they are currently reading an old post which might not be up to date. Here’s an out-of-the-box solution to do it. Paste the following code in your single.php file, within the loop. Edited the text on line 7 as desired. <? $ageunix = get_the_time(‘U’); $days_old_in_seconds = ((time() – $ageunix)); $days_old = (($days_old_in_seconds/86400)); if ($days_old > 365) { echo ‘<div class=”disclaimer”>DISCLAIMER: this post… Read More »WordPress tip: How to display a disclaimer on posts older than one year

      close-comments

      Inform user about automatic comment closing time

        To prevent spammers from flooding old articles with useless comments you can set WordPress to close comments after a certain number of days: It might be surprising for some users if the comments are closed automatically so it might be a good idea to inform them about the remaining time. add_action( ‘comment_form_top’, ‘topic_closes_in’ ); function topic_closes_in() { global $post; if ($post->comment_status == ‘open’) { $close_comments_days_old = get_option( ‘close_comments_days_old’ ); $expires = strtotime( “{$post->post_date_gmt} GMT” ) + $close_comments_days_old * DAY_IN_SECONDS; printf(… Read More »Inform user about automatic comment closing time

        How to Test the Security of Your WordPress Site

          WordPress continues to be one of the most popular content management systems, claiming over 58% of the market share as of January 2017. However, this popularity also makes WordPress sites an attractive target for hackers. According to website security firm, Sucuri, 75% of all websites hacked in the first quarter of 2016 were built on the WordPress platform. Due to these statistics, many have criticized WordPress as being an insecure platform, but this is not actually the case. WordPress in… Read More »How to Test the Security of Your WordPress Site