Forums

[resolved] Plugin that adds a page and protects it to only logged in users (5 posts)

  1. marketing guy
    Member
    Posted 9 months ago #

    I'm creating a plugin that adds a page using wp_insert_post. However, I need this page to only be accessible by logged in users. I tried to use !is_user_logged_in() but that doesn't work. Seems like post_content only accepts HTML, and not PHP. Which makes sense. I guess I need to know how I can execute PHP code on that newly created page. Any way to attach additional code?

  2. Digest WP
    Member
    Posted 9 months ago #

    Hello,

    This may help
    http://wordpress.org/extend/plugins/shortcode-exec-php/

    This plugin was made for that http://wordpress.org/extend/plugins/exec-php/ but has not been updated in a while. Could still work though for you

  3. marketing guy
    Member
    Posted 9 months ago #

    Oh I see how it works. I kinda want something like that but not have my plugin depend on that plugin, if it makes sense? Any other suggestions?

    I'll keep this one in my back pocket in case there are no alternatives. Thanks

  4. Digest WP
    Member
    Posted 9 months ago #

  5. marketing guy
    Member
    Posted 9 months ago #

    Cool, that helps. I'm just going to use add_filter to hook a function with all the PHP code to the_content action. :)

    Thanks again!

Reply

You must log in to post.

About this Topic