Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Jeff Starr

    (@specialk)

    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).

    Thread Starter lshr

    (@lshr)

    Very helpful. Thanks.

    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?

    I use twenty ten theme

    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 } ?>

    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?

    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]

    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.

    @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.

    MaruscaGabriel

    (@maruscagabriel)

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

    @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

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

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Limiting posts to registered users’ is closed to new replies.