Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter stuudio

    (@stuudio)

    This must only show up, when post is submitted by regular user or unregistered user.

    Plugin Author Jeff Starr

    (@specialk)

    You could do this by editing the theme template. For example, here is one way to do it via functions.php:

    // USP prefix submitted content
    function my_the_content_filter($content) {
    	global $post;
    	$usp_author = get_post_meta($post->ID, 'user_submit_name', true);
    	if (usp_is_public_submission()) {
    		$content = $usp_author . ' writes: ' . $content;
    	}
    	return $content;
    }
    add_filter('the_content', 'my_the_content_filter');
    Thread Starter stuudio

    (@stuudio)

    Thank you.

    Thread Starter stuudio

    (@stuudio)

    Thank you but we still have a small problem.
    This works fine in front page but not in single post view.

    Thread Starter stuudio

    (@stuudio)

    This is “not resolved”. Please do not mark this as resolved.

    Plugin Author Jeff Starr

    (@specialk)

    Could be an issue with whatever theme you are using.. the code just works by filtering the content wherever it is displayed using the_content().

    Apologies for marking the thread as “resolved”, it seemed pretty resolved to me.

    Let me know if any further questions or confusion, glad to help.

    Thread Starter stuudio

    (@stuudio)

    I hope I am not wasting you time. I am not a programmer so it’s possible I am talking rubbish. 🙂

    I searched and searched a bit more and it sounds to me that the_content returns content with a line-brake in front of it unless a filter is used.
    Filter you posted, works nice in front page but not in single post view.

    This is how my content.php looks like (post page)

    <?php if ( is_singular() ) { ?>
    
    		<header class="entry-header">
    			<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
    			<?php echo apply_atomic_shortcode( 'byline', '<div class="byline">' . __( 'Published by [entry-author] on [entry-published] [entry-comments-link before=" | "] [entry-edit-link before=" | "]', 'path' ) . '</div>' ); ?>
    		</header><!-- .entry-header -->
    
    		<div class="entry-content">
     			<?php  the_content(); ?>
    ....

    And it return:
    BlaaBlaa writes: (paragraph tag p line brake)
    What ever he/she wrote blaa blaa blaa…

    same time, on the front page, where only excerpt is returned, I get

    BlaaBlaa writes: What ever he/she wrote blaa blaa blaa…

    Do you see the difference.
    One has a line brake after the “user name writes:”

    Plugin Author Jeff Starr

    (@specialk)

    Thanks stuudio!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How can I include user_submit_name value in the post’ is closed to new replies.