WordPress.org

Forums

User Submitted Posts
[resolved] Required Login option return errors 2 out of 3 methods (5 posts)

  1. iambob
    Member
    Posted 1 year ago #

    Hi Jeff,

    I'm getting finicky results with the different methods for requiring login to submit:

    1) When I try the method mentioned on the FAQ page, I get a blank page on the front-end (user not logged in), and Admin back-end shows these errors (using Suffusion theme/child function.php on sandbox wtaz.smoothgrind.net):

    Warning: Cannot modify header information - headers already sent by (output started at /wtaz/wp-content/plugins/user-submitted-posts/user-submitted-posts.php:248) in /wtaz/wp-includes/option.php on line 563

    Warning: Cannot modify header information - headers already sent by (output started at /wtaz/wp-content/plugins/user-submitted-posts/user-submitted-posts.php:248) in /wtaz/wp-includes/option.php on line 564

    2) When I try the wp-mix.com syntax, I still get the submission form - i.e., 'return "Please login to submit posts."; - seems to have no effect. And yep, replaced the [your-plugin-shortcode] with [user-submitted-posts] / not using template tag.

    3) When I try the (wrapped short-code) method noted on http://wordpress.org/support/topic/newbie-questions-re-authors?replies=2, that works just fine/as expected ... yeah!

    3a) ... and might there be a trick to link to /wp-login.php within the pre-wrapper wrapper, e.g., [usp_member deny="Please log in to submit posts."] ?
    Just thinking it'd be nice for the user since their attention is right there.

    Thanks in advance for any remarks!
    Bob

    p.s. Dude, you make all other plugin developers look like chump-change re: [resolved], [resolved], [resolved], [resolved], [resolved], [resolved]! :-)

    https://wordpress.org/plugins/user-submitted-posts/

  2. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Just to be clear for anyone else reading the thread, the USP plugin works fine; you're asking about the 3rd party scripts that people are using to require users to be logged in.

    That said, it sounds like something else is interfering. I say that mostly because the methods for requiring users to log in are about as basic as they get. Here is the essence of what the code is doing:

    <?php if ( is_user_logged_in() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    } ?>

    So something like that should definitely work -- it's basically one template tag, so if there are any errors, something else is up. Maybe a plugin, theme, server config, etc.

  3. iambob
    Member
    Posted 1 year ago #

    Yes, copy that ... always many ways to accomplish the same thing. If further use and testing/troubleshooting reveals what might be interfering with methods 1 or 2 I've got a note to update this post, but best not to hold one's breath!

    As for 3a) ... hyperlink within the pre-wrapper possible?

    Thanks Jeff!

  4. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Yes absolutely there is -- just use single quotes for the href value, like so:

    [usp_member deny="Please <a href='/login.php'>log in</a> to submit posts."]

    Or if that doesn't work you can just change the shortcode:

    function usp_member($attr, $content = null) {
    	extract(shortcode_atts(array(
    		'deny' => '',
    	), $attr));
    	if (is_user_logged_in() && !is_null($content) && !is_feed()) return $content;
    	return "Please <a href='/login.php'>log in</a> to submit posts.";
    }
    add_shortcode('usp_member', 'usp_member');
  5. iambob
    Member
    Posted 1 year ago #

    Nope, and yep.

    Option A returns the raw syntax, too:

    Please log in to submit posts.

    Option B worked once deny="Please log in to submit posts." was removed from the pre-wrapper.

    Super, thanks again Jeff. Next customer ...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Submitted Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic