1

Trying to get a simple plugin and got error in my first steps..

<?php /* Plugin Name:!test */ require_once(includes_url() . '/pluggable.php'); function is_user_logged_in() { $user = wp_get_current_user(); return $user->exists(); } echo is_user_logged_in(); ?> 
3
  • Could you mention the error here? Commented Oct 30, 2016 at 13:01
  • Is it all the core of your plugin? If yes, it's incorrect. You need to define plugins meta first, and after add a shortcode, action and so on, depended on your task. For more information, read this Writing a Plugin Commented Oct 30, 2016 at 13:07
  • @Akshay Fatal error: Cannot redeclare is_user_logged_in() Commented Oct 30, 2016 at 13:09

1 Answer 1

1

You can't call function directly in your plugin file. Instead of it, call it inside the hook, for ex.:

function my_shortcode_func( $atts ) { $user = wp_get_current_user(); return $user->exists(); } add_shortcode( 'my_shortcode', 'my_shortcode_func' ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.