Codeless
  • Support Home
  • Themes
  • Support
  • WordPress Tutorials
    • How to Start a Blog
    • Best Website Builders
    • Best Small Business Hosting
    • Email Marketing Services
    • Cheap WordPress Hosting
  • Video Tutorials

Community Forums

Can’t Run This Code???

cookiecustom codelogin
    • 9 years ago rlambertiv
      Participant

      Expired

      Hello.

      I have the following WP Hooks that I am trying to run:

      /**

       *  remove admin bar for member registrants

       */

      add_action(‘after_setup_theme’, ‘remove_admin_bar’);

      function remove_admin_bar() {

      if (!current_user_can(‘administrator’) && !is_admin()) {

      show_admin_bar(false);

      }

      }

      /**

      *  extend wp logged in cookie to one year

      */ 

      add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in_for_1_year’ );

      function keep_me_logged_in_for_1_year( $expirein ) {

      return 31556926; // 1 year in seconds

      }

      I have attempted to run this code by placing it in the following locations:

      • /wp-content/themes/specular/functions.php
      • /wp-content/themes/specular/includes/register/functions.php
      • /wp-content/themes/specular/functions-specular.php

      Unfortunately, the code is not being executed. Where can I place this code to make it execute?

    • 9 years ago Mirela
      Participant

      Hello,

      Thank you for contacting us.
      The issue is not where you put the code, but the code itself. Please edit it to this:

      /**
      
       *  remove admin bar for member registrants
       */
      
       
      
      add_action('after_setup_theme', 'remove_admin_bar', 1);
      
      function remove_admin_bar() {
      
          if ( !current_user_can('administrator')  && !is_admin() ) {
      
              show_admin_bar(false);
      
          }
      
      }
      
      /**
      
      *  extend wp logged in cookie to one year
      
      */ 
      add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year', 99);
      
      function keep_me_logged_in_for_1_year( $expirein ) {
          return 31556926; // 1 year in seconds
      }

      And paste it in file functions.php.
      Let us know how it will go.

      Best regards!

Viewing 1 reply thread

You must be logged in to reply to this topic.

Login

Log In
Register

Renew Support

  • Renew Specular Support
  • Renew Tower Support
  • Renew Folie Support
  • Renew Handel Support
  • Renew June Support
  • Renew Picante Support
  • Renew Thype Support
  • Renew Regn Support

Search Forums

Forums

  • Bygge – Construction Theme
  • Converta – Software Theme
  • Folie – The WordPress Website Builder
  • Handel – Responsive Multi-Purpose Business Theme
  • June WooCommerce WordPress Theme
  • Livecast – Podcast Theme
  • Picante – Restaurant & Food WordPress Theme
  • Regn | Agency & Business WordPress Theme
  • Remake – Minimal Portfolio & Agency Theme
  • Specular – Multi-Purpose WordPress Theme
  • Suggest us Features
  • Tower – Business-Driven Multipurpose WP Theme
  • Vibrance – Photography Theme

Site Links

  • Support Policy
  • Specular Support Forum
  • Video Tutorials
  • Knowledge Base
  • Guides and Reviews

Useful Articles

  • Build a Website
  • Web Design & Development
  • Hosting
  • WordPress

Login

Log In
Register Lost Password