WordPress.org

Support

Support » How-To and Troubleshooting » single pages with user profile field

single pages with user profile field

Viewing 10 replies - 1 through 10 (of 10 total)
  • Serge
    Participant

    @gholem

    Hi @hartlrobert ,

    1. You want to have a page with all the users (companies, in this case) listed and all those users to have more details than just the names?

    2. Or you want to have a profile page for every user (company) and that profile page to display more than just the name?

    For the number 2 question, check out this tip on how to add or remove fields from user’s profile.

    Once you added/removed the fields to/from the profile, use the Author Templates tags to display it.

    For the number 1 question things go pretty much the same.

    Robert
    Member

    @hartlrobert

    Hi @gholem,

    I have normal users with user lists and user single pages based an user login name (normal WordPress way).
    Users have extra fields (compnay name, company description, …). I’d like to display a company list (simple user listing with only company fields shown) AND -> company single pages. How is this possible?

    Serge
    Participant

    @gholem

    This will display a list of all users, except admin:

    <ul>
    <?php wp_list_authors('exclude_admin=0&optioncount=1&show_fullname=1&hide_empty=1'); ?>
    </ul>

    Parameters for this:

    exclude_admin: 0 or 1 (include or exclude the admin’s name from the list)
    optioncount : 0 or 1 (display or not author’s post count)
    show_fullname : 0 (display first name only) / 1 (display full name of the author)
    hide_empty : 0 (display authors with no posts) / 1 (display authors who have one or more posts)

    To link each author to their own page: <?php the_author_link(); ?> This will display a link to author page.

    To get the author: <?php get_the_author_link(); ?>

    Have a look at the Author Tags.

    You can also find free plugins to deal with users:
    http://wordpress.org/extend/plugins/members-list/
    http://wordpress.org/extend/plugins/wordpress-users/

    Serge
    Participant

    @gholem

    *Actually, this is to get the author link in PHP, my mistake: <?php get_the_author_link(); ?>

    The difference between author tags and author templates is that the first ones deal with anything author-related anywhere in your website (for example, to have a list of authors with some details to each author and a link to their own pages) and the second ones (author templates) deals with the authors profile pages only.

    Hope I understood your question correctly and I’ve replied coherently enough to it.

    Robert
    Member

    @hartlrobert

    Hm, I’m not sure.

    I have:
    – author list
    – author single pages
    – company list(s)

    I not have:
    – company single page

    For example:
    /authors/ -> author listing
    /authors/login-name/ -> author single page
    /companies/ -> company listing (author listing with only company profile fields shown)

    Question:
    /companies/company-name/ -> company single page, how could that be possible??

    Thank you!

    Serge
    Participant

    @gholem

    Isn’t it easier to just create the company page profile from backend?

    And just link to every company page from your companies list page?

    Otherwise I’m lost, I’m sorry.

    keesiemeijer
    Moderator

    @keesiemeijer

    You can add new rewrite rules. Maybe this will help you on your way: http://wordpress.org/support/topic/adding-sub-pages-to-custom-rewrite-url

    Robert
    Member

    @hartlrobert

    I supposed that this could be difficult. With the rewrite rules it could be possible if i can geht the company url to list the author page (and show only the company fields).

    Because the authors should updating their company informations, backend only isn’t enough.

    Thank you very much so far!

    keesiemeijer
    Moderator

    @keesiemeijer

    What you could try is create a normal page called companies. Give it a custom page template where you show all the companies.

    Download a rewrite class from here: http://www.refactord.com/adding-rewrite-rules-to-wordpress

    Put it in your theme’s functions.php and put something like this after it and re-save your permalinks:

    $options = array(
      'rules' => array(
      '(companies)/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&company=$matches[2]$&paged=$matches[3]',
      '(companies)/(.+?)/?$' => 'index.php?pagename=$matches[1]&company=$matches[2]',
    
      ),
      'query_vars' => array('company')
    );  
    
    $add_rewrite_rules = new Refactord_add_rewrite_rules($options);

    Now on the company page (template) you could link to yoursite/companies/company_name (and not get a 404)

    On your custom page tempplate you could test if the company query var is used:

    $company = get_query_var('company');
    if($company){
    // here you test if the company exists
    // and show the company info
    }

    Not sure if this is the best way to go though.

    Robert
    Member

    @hartlrobert

    Wow, that sounds pretty good, thank you keesiemeijer!
    I’ll give it a try.

    Otherwise I could make a custom post type “companies” and let the registered authors create one post. Maybe this is more WordPress like, but frontend creation …

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘single pages with user profile field’ is closed to new replies.