WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. el terrible bmw
    Member
    Posted 1 year 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 1 year 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. el terrible bmw
    Member
    Posted 1 year 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 1 year ago #

  5. el terrible bmw
    Member
    Posted 1 year 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!

Topic Closed

This topic has been closed to new replies.

About this Topic