Support » Plugin: WordPress Membership Plugin - Restrict Content » I want to add shortcode to the external php program to limit the content

  • Resolved xinglin

    (@xinglin)


    I want to add [restrict] shortcode to the external php program to limit the content,
    how do I add it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • xinglin

    (@xinglin)

    This is the plugin code. how can i add [restrict] shortcode at here?

    	if ( isset($read_setting['read_content']) && $read_setting['read_content']  === 'true' ) {
    			$entry_output .= '
    					<div class="gb-entry-content">';
    
    			// Use this filter to just add something
    			$entry_output .= apply_filters( 'gwolle_gb_entry_read_add_content_before', '', $entry );
    
    			$entry_content = gwolle_gb_sanitize_output( $entry->get_content(), 'content' );
    			if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
    				$entry_content = nl2br($entry_content);
    			}
    			if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled']  === 'true' ) {
    				$entry_content = gwolle_gb_bbcode_parse($entry_content);
    			} else {
    				$entry_content = gwolle_gb_bbcode_strip($entry_content);
    			}
    			$excerpt_length = (int) get_option( 'gwolle_gb-excerpt_length', 0 );
    			if ( $excerpt_length > 0 ) {
    				$readmore = '... <a href="#" class="gwolle_gb_readmore gwolle-gb-readmore" title="' . esc_attr__('Expand this entry and read more', 'gwolle-gb') . '">' . esc_html__('Read more', 'gwolle-gb') . '</a>';
    				$entry_excerpt = wp_trim_words( $entry_content, $excerpt_length, $readmore );
    				$entry_content = '
    						<div class="gb-entry-excerpt">' . $entry_excerpt . '</div>
    						<div class="gb-entry-full_content gwolle_gb_hide">' . $entry_content . '</div>';
    			}
    			if ( get_option('gwolle_gb-showSmilies', 'true') === 'true' ) {
    				// should be done after wp_trim_words to keep all the smileys intact.
    				$entry_content = convert_smilies($entry_content);
    			}
    			$entry_output .= $entry_content;
    
    			// Use this filter to just add something
    			$entry_output .= apply_filters( 'gwolle_gb_entry_read_add_content', '', $entry );
    
    			$entry_output .= '
    					</div>';
    Plugin Author Ashley

    (@nosegraze)

    Because you’re working with PHP, using a shortcode isn’t the best option. Instead I’d recommend using a PHP conditional function like current_user_can().

    For example, you might add this at the beginning where you want to start blocking content:

    if ( current_user_can( 'edit_posts' ) ) {

    then this at the end to end the restriction:

    }

    Change edit_posts to the capability you want to require users to have in order to read the content.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I want to add shortcode to the external php program to limit the content’ is closed to new replies.