WordPress.org

Ready to get started?Download WordPress

Forums

User Submitted Posts
[resolved] Limiting posts to registered users (13 posts)

  1. lshr
    Member
    Posted 1 year ago #

    I would like to limit user posts to registered (signed in) users so that their content will have their user name as the author. I am also hoping it will help keep spam and moderation requirements down.

    Is there a time frame for adding that feature to USP. It's up and working and it looks good.

    Thanks!

    http://wordpress.org/extend/plugins/user-submitted-posts/

  2. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    I may add that feature in a future update, but there's no need to wait. WordPress makes it easy to display content only to logged-in users. Here is an example:

    <?php // USP require login
    global $user_identity, $user_ID;
    if(current_user_can('read')) { ?>
    
    <?php if (function_exists('user_submitted_posts')) user_submitted_posts(); ?>
    
    <?php } else { ?>
    
    <?php // do something for visitors who are not logged in.. ?>
    
    <?php } ?>

    For example, if you place that code in your sidebar.php file, the USP form will be displayed only for logged in users. Visitors not logged in won't see anything (unless you add something like a registration form or whatever).

  3. lshr
    Member
    Posted 1 year ago #

    Very helpful. Thanks.

  4. psyche83
    Member
    Posted 1 year ago #

    I inserted the shortcode into a new page, the plugin works fine.

    But I inserted this code into sidebar.php and I still can see the submitting site with the fields when I am logged off. It is the same like I am logged on.

    I tried to place this code in the and of page.php as well, but it does not work neither.

    So I do not use it on my sidebar, I want it on a page...What is the problem?

  5. psyche83
    Member
    Posted 1 year ago #

    I use twenty ten theme

  6. chase78
    Member
    Posted 1 year ago #

    Hi,

    Can someone help me on this. I create the Submit Review form as a page. The page editor only accepts HTML input and not the PHP below. Does anyone know how to get round this simple problem? Thank you.

    <?php // USP require login
    global $user_identity, $user_ID;
    if(current_user_can('read')) { ?>

    <?php if (function_exists('user_submitted_posts')) user_submitted_posts(); ?>

    <?php } else { ?>

    <?php // do something for visitors who are not logged in.. ?>

    <?php } ?>

  7. 1BJK903
    Member
    Posted 1 year ago #

    What do you mean that it does not accepts the PHP? Are you trying to edit it on the backend or are you using a widget or something?

  8. LapanWebsite
    Member
    Posted 11 months ago #

    add_shortcode( 'member', 'member_check_shortcode' );
    
    function member_check_shortcode( $atts, $content = null ) {
    	 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
    		return $content;
    	return '';
    }

    Usage:
    [member][user-submitted-posts][/member]

  9. taxman10m
    Member
    Posted 9 months ago #

    The [member] shortcode doesn't work for me.

    All I get on my page is the text: [user-submitted posts].

    And if I remove the [member] tags the form shows up ok.

  10. LapanWebsite
    Member
    Posted 9 months ago #

    @taxman10m, there was a mistake in code, I noticed now.

    Try this:

    add_shortcode( 'member', 'member_check_shortcode' );
    
    function member_check_shortcode( $atts, $content = null ) {
    	 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
    		return do_shortcode($content);
    	return '<p>Please register to add content.</p>';
    }

    Usage:
    [member][user-submitted-posts][/member]

    I missed to add do_shortcode on content inside [member] shortcode.
    Now, it should work.

  11. MaruscaGabriel
    Member
    Posted 7 months ago #

    @LapanWebsite Thank you! You solve this. It works great.

  12. anandrej
    Member
    Posted 6 months ago #

    @LapanWebsite. Your code looks useful, but can you please tell me where and which file this code([member]) should be added?. I'm looking for a similar solution for a problem and I'm lost as to where this has to be included. I have user submitted form but for users to add data I want them to be registered. I will appreciate if you can reply back asap. Thanks in advance

  13. anandrej
    Member
    Posted 6 months ago #

    Never mind. I figured it out myself and it works perfect as I expected. Thanks for the great hint , it helped me immensely.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.