Skip to:
Content
Pages
Categories
Search
Top
Bottom

Menu link to Profile

Viewing 25 replies - 1 through 25 (of 36 total)
  • @robin-w

    Moderator

    Strangely this is quite difficult to achieve, as the url for a user profile edit is

    http://mysite.com/forums/users/username/edit/

    where the username is the actual username of the person logged in.

    so you can’t add it as a menu item as far as I can work out.

    2 solutions to this :

    Solution 1 – the harder way !
    One solution and the one I use is adding this as a line in the login widget, so that it appears under the “account” in your sidebar

    I use the (bbpress) Login widget for the sidebar. This widget is set up in

    wp-content/plugins/bbpress/includes/common/widgets.php

    I added this line after line 145

    line 145 reads
    <?php bbp_logout_link(); ?>

    and I add a new line 146 saying

    <p><a href="<?php bbp_user_profile_url( bbp_get_current_user_id() ); ?>edit" >Amend Profile/Change password</a></p>
    This then comes up when someone is logged in

    Of course you’ll need to make a note of this change, as it is lost whenever you upgrade bbpress versions

    the advantage (and why I use it ) is it then only gives this line when someone is logged in

    Solution 2 – the easier way

    If you’re not keen to change code, the download the enhanced text widget

    https://wordpress.org/plugins/enhanced-text-widget/

    Then in your sidebar add the enhanced text widget, and put this code in content, check the “don’t display header” and click save

    <p><a href="<?php bbp_user_profile_url( bbp_get_current_user_id() ); ?>edit" >Amend Profile/Change password</a></p>

    Much easier to do, but displays whether someone is logged on or not.

    @mmichael1991

    Participant

    You sir, are my hero!

    That did the trick.

    I hope they can somehow add this in an future update.

    Many thanks!!

    @robin-w

    Moderator

    You’re very welcome !

    @mmichael1991

    Participant

    It doesn’t seems to work on the new 2.5 update..

    Have you tried the new update yet?

    @robin-w

    Moderator

    Which of the solutions above did you use?

    @mmichael1991

    Participant

    Hi, I used the first solution.

    But after when I looked at the code of my site, I noticed something strange.
    It shows the text behind the logout button.
    Pic (link to dropbox): https://dl.dropboxusercontent.com/u/17971771/site.png

    So has this something to do with my theme? Or can I simply fix this within bbPress?

    Thanks for your help!

    @diggories

    Participant

    I don’t know if this will help or not however I have found a simple way to do a text link in a page or post.

    I use the below PHP to call the current user

    <?php global $current_user;
          get_currentuserinfo();
    
         echo  $current_user->user_login . "";
          
    ?>

    And then surround it with a standard html link.

    <a href="http://yoursite.com/forums/users/<?php global $current_user;
          get_currentuserinfo();
    
         echo  $current_user->user_login . "";
          
    ?>">My Profile</a>

    I use a plugin called Hana Code Insert to place it in posts and pages using the following steps:

    1.) Take the php code

    <?php global $current_user;
          get_currentuserinfo();
    
         echo  $current_user->user_login . "";
          
    ?>

    and place it in the “New Entry” box in the Hana Code Insert plugin and give it a name like “BB Profile” or what ever you want.

    2.) Tick the “Evaluate as php code.” check box at the bottom of the “New Entry” field.

    3.) Click “Create New Entry” and this will produce a shortcode something like this [hana-code-insert name='BB Profile' /]

    4.) Then on the page or post you want to place the link just place the following <a href="http://yoursite.com/forums/users/[hana-code-insert name='BB Profile' /]">My Profile</a>

    That’s it, hope it helps and I.m sure someone here can figure a way to use this in a menu link, I am still trying to figure that out.

    @diggories

    Participant

    oh if you want it to go directly to the edit profile section just add /edit at the end like this

    <a href="http://yoursite.com/forums/users/[hana-code-insert name='BB Profile' /]/edit">My Profile</a>

    @robin-w

    Moderator

    Diggories,

    Some great tips there.

    mm, the upgrade will have overwritten the change – as per first post

    Of course you’ll need to make a note of this change, as it is lost whenever you upgrade bbpress versions

    I haven’t upgraded yet, let me know if putting it back fixes it !

    @mmichael1991

    Participant

    Hi

    I already tried that. Doesn’t work. Only when replacing the updated bbPress plugin folder back to the previous version.

    I started a Topic of this on my theme support page. So maybe they can find a solution.
    Here.

    @robin-w

    Moderator

    Ok thanks I’ll take a look, but sounds like 2.5 has changed the way profiles are displayed
    ie when you click an avatar it now goes to a smaller screen selection.

    @robin-w

    Moderator

    Just upgraded my test site to 2.5, and with the twentyten theme I run, the profile link takes you to a page with

    profile
    topics started
    replies created
    favorites
    subscriptions
    edit

    Just as it did before !

    I use solution 1, so I have just added the oine to the new widgets file and uploaded it, and all works fine.

    @freewpress

    Participant

    Little off topic.. Hi robin can you test if when you subscribe one forum it appear in user subscriptions page? Thanks…

    @robin-w

    Moderator

    Tested – I subscribed, but in profile it says

    “subscriptions

    You are not currently subscribed to any forums.”

    So no that doesn’t seem to work.


    @Stephen
    Edgar – any ideas 2.5 working in twentyten !

    @freewpress

    Participant

    Ok, please report your feedback here please https://bbpress.trac.wordpress.org/ticket/2480
    Many thanks for your time…

    @mmichael1991

    Participant

    Hmm..

    Then it supposed to be a theme malfunction then.

    @ronthai

    Participant

    I just added to my menu all forum links from a user:
    topics, replies, favorites, subscriptions, edit
    all under 1 main “Your Forum Settings & Stats” Dropdown, but just call it anything you want.

    Get the plugin “WP exec PHP” : https://wordpress.org/plugins/wp-exec-php/
    No security risk, since you can set the permission for who can add php to pages and such.

    Create pages for any links to the profile you want and add the following REDIRECT with php-code in it (adjust to your own domain)

    <meta http-equiv="refresh" content="0;URL=http://domain.com/forums/users/<?php global $current_user;
          get_currentuserinfo();
    
         echo  $current_user->user_login . "";
          
    ?>/edit/">

    You could delay the refresh and add a little text to the page, or anything you want.

    With many thanks to Diggories (above somewhere) for the php code to get the username in a URL

    @ronthai

    Participant

    If your theme supports blank pages (Page Attributes), use that to give the “illusion” that it is not a redirect.

    The above link+php is for the edit page.
    If you look at the link after URL you see: partial_url/php_code/last_part_of_the_URL

    The last part of the URL is what you have to change for the topics, replies, favorites, subscriptions or edit

    @diggories

    Participant

    @ronthai Thanks for the “How To” for creating menu links. I have already implemented it on two of my sites and it works great.

    Again Thanks

    @lee990

    Participant

    hi I used a plug in called theme my log in by amending the code it only displays when the user is logged in. I don’t know if it works with other login modules or the same theory applies, but only took 10mins to do and I know nothing about php.

    Good luck

    and the added the code as suggested by Robin W on this thread

    <p>edit” >Amend Profile/Change password</p>

    I edited the file in theme my login, wp-content/plugins/theme-my-login/templates/user-panel.php
    and added the code in, so the whole file looks like;

    <?php

    /*

    If you would like to edit this file, copy it to your current theme’s directory and edit it there.

    Theme My Login will always look in your theme’s directory first, before using this default template.

    */

    ?>

    <div class=”login” id=”theme-my-login<?php $template->the_instance(); ?>”>

    <?php if ( $template->options[‘show_gravatar’] ) : ?>

    <div class=”tml-user-avatar”><?php $template->the_user_avatar(); ?></div>
    <p></BR>edit” >Amend Profile / Change password</p>

    <?php endif; ?>

    <?php $template->the_user_links(); ?>

    <?php do_action( ‘tml_user_panel’ ); ?>

    </div>

    it looks really good, well I think so.

    @robin-w

    Moderator

    Thanks lee990, that looks like a smarter way to do it – I give it a try when I get a moment !

    @aravindbachu

    Participant

    @ronthai … your method seems good. can you please me more precise? where do we have to add that code and what should we change for other links?

    @robin-w

    Moderator

    Ronthai – have just tried it for profile, and it works well

    Summary of what I did

    In Dashboard>plugins>add new
    Search for WP exec PHP, install and activate

    Create a new page called “profile” or whatever name you want

    In content of this page, add this code

    <meta http-equiv="refresh" content="0;URL=http://mysite.com/forums/users/<?php global $current_user;
          get_currentuserinfo();
    
         echo  $current_user->user_login . "";
          
    ?>/edit/">
    

    Where mysite.com is your site name

    If using custom menus, add the page to the menu.

    And it works !

    @mathijs-lemmers

    Participant

    It’s been a long time but I have a problem with the last provided code. It should would perfect, were it not that my username contains a space. And the code doesn’t change a space to a dash.

    Could the code above be modified to achieve this?

    Thanks so much in advance!

    @robin-w

    Moderator

    ok try this, which should tidy most usernames

    <meta http-equiv="refresh" content="0;URL=http://mysite.com/forums/users/
    <?php global $current_user;
          get_currentuserinfo();
    $string = $current_user->user_login ;
         //Lower case everything
        $string = strtolower($string);
        //Make alphanumeric (removes all other characters)
        $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
        //Clean up multiple dashes or whitespaces
        $string = preg_replace("/[\s-]+/", " ", $string);
        //Convert whitespaces and underscore to dash
        $string = preg_replace("/[\s_]/", "-", $string);
        return $string;
    echo $string . "";      
    ?>/edit/">
    
Viewing 25 replies - 1 through 25 (of 36 total)
  • You must be logged in to reply to this topic.
Skip to toolbar