WordPress.org

Ready to get started?Download WordPress

Forums

User Submitted Posts
[resolved] How can I include user_submit_name value in the post (9 posts)

  1. stuudio
    Member
    Posted 6 months ago #

    How can I include user_submit_name value in the post so it looks like this:

    "user_submit_name here" writes: Blaa blaa blaa aka what ever he wrote

    Thank you

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

  2. stuudio
    Member
    Posted 6 months ago #

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

  3. Jeff Starr
    Member
    Plugin Author

    Posted 6 months ago #

    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');
  4. stuudio
    Member
    Posted 6 months ago #

    Thank you.

  5. stuudio
    Member
    Posted 6 months ago #

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

  6. stuudio
    Member
    Posted 6 months ago #

    This is "not resolved". Please do not mark this as resolved.

  7. Jeff Starr
    Member
    Plugin Author

    Posted 6 months ago #

    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.

  8. stuudio
    Member
    Posted 6 months ago #

    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:"

  9. Jeff Starr
    Member
    Plugin Author

    Posted 4 months ago #

    Thanks stuudio!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.