0

Here is my code and I want to know what is shortcode of this? Is it [login_form] or do we need to add something more? With [login_form] there is no output as result

function pippin_login_form() {

if(!is_user_logged_in()) {

    global $pippin_load_css;

    // set this to true so the CSS is loaded
    $pippin_load_css = true;

    $output = pippin_login_form_fields();
} else {
    // could show some logged in user info here
    // $output = 'user info here';
}
return $output;
}
add_shortcode('login_form', 'pippin_login_form');
0

You are correct, [login_form] is the shortcode that you should use. From the Shortcode API

The add_shortcode function is used to register a shortcode handler. It takes two parameters: the shortcode name (the string used in a post body), and the callback function name.

From what I can understand is that the shortcode calls a customized login form defined in a function called pippin_login_form_fields(); There might be a couple of reasons that your shorcode does not display anything

  • You are logged in. The shortcode first does a check to see if a user is logged in or not (if(!is_user_logged_in()) {). If a user is not logged in, the login form is displayed. When a user is logged in, nothing is displayed.

  • There might be some type of error in the pippin_login_form_fields(); function or it is misplaced/missing

  • Some other function or filter is breaking your shortcode.

If point one is not the problem, turn on debugging in wp-config.php and check for any errors. To debug wordpress, go and check this article: Debugging in Wordpress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.