Login form when access the content


I put a text in the “Content Protection Options” saying that the user needs to login to access the content.

What should I write to get a login form after that text? I think it’s stupid to let the user go to another place to login and then try to get back again…

Is there a way to use a shortcode like this: [login submit_value=”Send” username_value=”Username…” password_value=”password” return_url=”http://www.my-super-domain/return_url”]

I have tried some plugins but it just render the shortcode

All the best


  • Alexander
    • DEV MAN’s Mascot

    Hey @securitas,

    This is actually because by default the “Protected content message” doesn’t allow for shortcodes.

    If it did, things could get messy. People could call more membership shortcodes from there, possibly causing an infinite loop and crashing the process.

    We might be able to work around this with something like this: apply_filters( ‘the_content’, $content );

    I’ll give this code a quick test a bit later when I have time and let you know if it’s possible.

    Best regards

  • Alexander
    • DEV MAN’s Mascot

    Hey again @securitas,

    Sorry about the delay here. Ok, so here it is. I was able to make this work.

    function process_shortcodes_override($options) {

    if ( ! is_admin() ) {
    if(!isset($options['shortcodemessage'])) { $options['shortcodemessage']=''; }
    $options['shortcodemessage'] = apply_filters('the_content',$options['shortcodemessage']);
    return $options;

    add_filter('option_membership_options', 'process_shortcodes_override');

    Just add this into a plugin, or your theme’s functions.php I’ve tested this and it works. It will allow you to use shortcodes in the “protected content” message. Use at your own risk. Remember, if you use any other shortcodes in here that would trigger the message to be shown again, you’ll throw this into a loop and probably cause the process to run out of memory and fail.

    Other than that disclaimer, it’s safe and you should be all set. Let me know how it goes if you try it out.

    Best regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.