• Whenever i search for this on google i only find out how to display certain things to certain users. This is obviously why i’ve failed to find out how to do this using this website’s search function as well.

    What i want to know how to do is how to add certain things to certain users.

    For example, how do i make the word “Moderator” appear next to the name of only ONE of my users? It should be displayed to all users, but i obviously don’t want to add the word “Moderator” next to the name of every user in my community.

    By the way, English is a secondary language to me, so could someone also tell me if what i’m looking for here is called something specific? What would a native English speaker enter into google to find out how to do what i’m asking for in this topic? “How to add content to specific members in wordpress” certainly doesn’t work.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You basically want to edit your theme template files. I’d need to know where on your website you want this done to give you an idea of exactly how to fix it.

    But here’s an example that might help you out…….

    Say you want to edit a single post’s display where the post lists the author’s name. That would be edited in the single.php file. In the code, you should see something like this….

    <?php the_author(); ?>

    That line will display whatever is selected in the “Display Name Publicly As: ” field in the user’s profile page. In our example, say the user’s name is “Bob Smith” and that is also what is selected as the public display name. Now we’ll edit the single.php file with this…

    <?php
         $author = get_the_author();
    
         if ( $author == 'Bob Smith' ) {
    
              echo $author. ' Moderator';
          }
         else {
    
              echo $author;
         }
    ?>

    Here’s what that code does.
    1. Sets the value of the $author variable to equal the result of the get_the_author() function (basically the same as the_author() function.
    2. Checks to see if the value of the $author variable is equal to ‘Bob Smith’, which is the name of the author you want to add the ‘Moderator’ tag to.
    3. If it IS, the value of the $author variable will print, followed by a space and the word Moderator.
    4. Otherwise, it will just display the author name as it usually would.

    That should give you a rough idea of what you’d have to do. Sorry for the lengthy explanation.

    Thread Starter Hysteriux

    (@hysteriux)

    Thanks for the excellent help! I’ll get to it and try this out right away!

    Thread Starter Hysteriux

    (@hysteriux)

    Well this works fine! It does however only add itself to single posts, which of course is a good start. But what i actually was after was a way to add something to a user’s name wherever his/her name shows up, everywhere on the website where it might. As it seems, the only way to do this in WP is to actually edit every file that displays names.

    In this case, i guess it’s almost too much to ask for anyone to know how to add things like CubePoints rank and awards won as little images next to a user’s name on a heavily extended website running BuddyPress.

    I bet someone however at least could help me figure out what to replace the correct code to use to fetch a user’s ID on different pages. The BP pages don’t use author but rather several different data to fetch each ID.

    Thread Starter Hysteriux

    (@hysteriux)

    Hmm, actually, BP doesn’t even use ” the_author(); “. It uses all of this:

    <?php printf( _x( 'by %s', 'Post written by...', 'buddypress' ), str_replace( '<a href=', '<a rel="author" href=', bp_core_get_userlink( $post->post_author ) ) ); ?>

    I guess asking this here was a mistake. I didn’t know that BP replaces WP entirely like this. I guess it’s because of the theme it uses.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add content related to specific members’ is closed to new replies.