WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding sub-pages to custom rewrite url (24 posts)

  1. haxxxton
    Member
    Posted 2 years ago #

    Hey guys,

    So i have a site where i have used the authors.php page so that i can display individual user's profile pages.. the url then looks something like:
    http://mydomain.com/user/haxxxton/

    What i would like to do is have it so that I can add subpages to this that are common for each user ie:
    http://mydomain.com/user/haxxxton/settings/

    is there a place i should be telling URL's of this structure to be redirecting to a specific file? and how would i do that?

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I would advise your users that you are attempting an insecure method of listing their profiles.

  3. haxxxton
    Member
    Posted 2 years ago #

    you're not really being very helpful Seacoast Web Design.. the site is a directory site.. it doesnt list things like their emails unless they want to.. which all users when the register will be told about in the terms and conditions of sign up..

    please post USEFUL responses to peoples forum questions.. as im noticing that your posts in other peoples topics are about as helpful..

  4. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Please spend more a few seconds clicking then copying and pasting.

  5. haxxxton
    Member
    Posted 2 years ago #

    could an admin please remove the last 3 posts as they are completely irrelevant to the issue.. Seacoast Web Design.. this is a How-To and Troubleshooting forum.. the idea is to direct people to help or provide it yourself.. neither of which you are doing.. please desist from hijacking this thread..

  6. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I am advising you and your users not to do what you want to do.

    to get a mod to pay attention add 'modlook' to the tags

  7. haxxxton
    Member
    Posted 2 years ago #

    Author Templates

    are default functionality of WordPress.. there is nothing INSECURE about displaying COMMON information about users that would similarly be displayed when the user made a comment.. or created a page..

    i am categorically telling you that i DO want to do this.. i can assure you that is why i am asking..

  8. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Templates are not default functionality. They may or many not include such, however.

  9. haxxxton
    Member
    Posted 2 years ago #

    both the TwentyTen and TwentyEleven DEFAULT themes that come WITH wordpress include Author Tempate files..

    I say again.. i DO want to do what i am asking.. unless you have something CONSTRUCTIVE to add.. please STOP hijacking this thread..

  10. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Have a read on Google:

    "wordpress security author template"

  11. haxxxton
    Member
    Posted 2 years ago #

    yep.. first 10 search results (HERE with quotes, and HERE without quotes) are either links to the function references that I have already provided, or people talking about security plugins with NO reference to ANY issues in the author template.. with the exception of PERHAPS THIS however, it is clearly his PERSONAL opinion about usernames vs emails..

    when you find evidence id be happy to listen.. but telling me to 'google it' doesnt really fill me with any strong belief that you know of any security issues outside of those that a privacy policy negates..

    THIRD TIME NOW IM GOING TO ASK YOU TO REFRAIN FROM POSTING ON THIS THREAD AS YOU HAVE NOTHING TO OFFER

  12. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    outside of those that a privacy policy negates

    Does it?

    Yes, that is in fact how that works, obscure search results are not on page 1.

  13. haxxxton
    Member
    Posted 2 years ago #

    so it's neither a point that occurs often enough that anyone raises it in forums NOR blog about it!? - again FILLING me with confidence of your proficiency on this subject

    if you want me to trawl through PAGES of google search results to find a site that MAYBE provides support to an issue that ONLY you thinks exists, im going to kindly ask you to get lost..

    either provide me with a link yourself.. or STOP POSTING ON THIS THREAD.. simples

  14. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I can provide advice, and do, take it at will.

  15. haxxxton
    Member
    Posted 2 years ago #

    That's great.. But generally, advice is given based on either experience or evidence.. Given you have provided me with neither its about as useful as posting 'I have a car. The car has an issue. Fix it' (for clarity - that's NOT useful)

  16. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    That was not this post. Was this one. It was exceedingly vague.

    Please refrain from huff here.

    I have helped many here and elsewhere.

    I just find your attempts ill-advised.

  17. haxxxton
    Member
    Posted 2 years ago #

    No huff here, merely an example of useless posting vs constructive posting..

    Your 'help' in this post hasn't been. You are providing personal opinion based on no evidence. I have repeatedly asked you to stop posting in this thread as you have nothing more to add than a vague notion.

    What the opening post is asking is perfectly reasonable and exists in themes like BuddyPress. Unless you know how to do it please do not post again. Your belligerent nature and overall lack of usefulness are unwanted here.

  18. keesiemeijer
    moderator
    Posted 2 years ago #

    Stop this bickering or I will close this post.

    Download a rewrite class from here: http://www.refactord.com/adding-rewrite-rules-to-wordpress
    Put it in your functions.php (without the opening <?php tag) and add this under it:

    $options = array(
      'rules' => array(
      'user/([^/]+)/(settings)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]'),
      'query_vars' => array('settings')
    );  
    
    $add_rewrite_rules = new Refactord_add_rewrite_rules($options);

    After re-saving your permalink structure you can go to http://mydomain.com/user/haxxxton/settings/

    In the same theme template file that is used for authors you can check if you are on a normal author Page or author settings Page like this:

    <?php
    $settingspage = get_query_var('settings');
    if($settingspage == 'settings' ) {
    	echo "show author settings here";
    } else {
    echo "show normal author archive page here";
    }
    ?>

    And as Seacoast Web Design says, don't show all profile information on the front end of your site.

  19. haxxxton
    Member
    Posted 2 years ago #

    Thanks keesiemeijer, but im not sure that it worked 100%..

    when i add the rewrite class and add your bottom addition i then changed and then changed back my permalink structure to refresh the rewrite rules as you mentioned

    however i get an error 404 when going to the settings page (http://mydomain.com/user/haxxxton/settings/)

    when i turn on $show_rules in the class I can see the newly added rewrite rule is present ([user/([^/]+)/(settings)/?$] => index.php?author_name=$matches[1]&settings=$matches[2])

    and when i turn on $show_query_vars in the class i can see the following at the top:

    Array
    (
        [page] => 0
        [name] => settings
        [category_name] => user/haxxxton
        [error] =>
        [m] => 0
        [p] => 0
        [post_parent] =>
        [subpost] =>
        [subpost_id] =>
        [attachment] =>
        [attachment_id] => 0
        [static] =>

    have i missed a step?
    much appreciated for the response.. any chance of having the posts above it removed for future browser's sake?

  20. keesiemeijer
    moderator
    Posted 2 years ago #

    any chance of having the posts above it removed for future browser's sake

    I'm sorry but it's not the general policy to edit or delete forum posts.: http://codex.wordpress.org/Forum_Welcome#Deleting_.2F_Editing_Posts

    That's strange, on my server it's working.

    Can you put this in your author template and visit the normal author Page (without /settings) and post the results here:

    <?php // find the matched rule (usefull for making a new rule)
    global $wp;
    echo empty($wp->matched_rule) ? 'None' : 'Rule= '.esc_html($wp->matched_rule); ?>
    <?php
  21. haxxxton
    Member
    Posted 2 years ago #

    the result is the following :

    Rule= trainer/([^/]+)/?$

    i have been changing the author_base parts manually when posting them up here.. should probably just post what's actually going on..

    so i have the code

    //redefine mod_rewrite rules for users
    function custom_author_base(){
    	global $wp_rewrite;
    	$wp_rewrite->author_base = 'trainer';
    }
    add_action('init', 'custom_author_base', 0 );

    above the rewrite class.. not sure if that is what is causing the error..
    is there a way to use your code and have 'user' be 'trainer'..

    also if i want to add more and more subpages eg. settings, posts, messages etc do i just add them to the section:
    query_vars' => array('settings')

    like
    query_vars' => array('settings', 'posts', 'messages')

  22. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with this:

    $options = array(
      'rules' => array(
        'trainer/([^/]+)/(settings)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]'),
      'query_vars' => array('settings')
    );  
    
    $add_rewrite_rules = new Refactord_add_rewrite_rules($options);

    also if i want to add more and more subpages eg. settings, posts, messages etc do i just add them to the section:

    You'll need to add them to the rules array and the query_vars array.
    example [untested]:

    $options = array(
      'rules' => array(
        'trainer/([^/]+)/(settings)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]',
        'trainer/([^/]+)/(messages)/?$' => 'index.php?author_name=$matches[1]&messages=$matches[2]'
    ),
      'query_vars' => array('settings','messages')
    );

    Re-save your permalink structure after adding the new rewrite rules

  23. haxxxton
    Member
    Posted 2 years ago #

    AWESOME!

    your untested thing worked great

    appreciate it mate :)

  24. keesiemeijer
    moderator
    Posted 2 years ago #

    You're welcome. I'm glad you got it resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic