How to link to user profile, user posts, subscribed topics,

Discussion forum for MOD Writers regarding MOD Development.
Locked
Clare1234
Registered User
Posts: 4
Joined: Fri Jul 05, 2013 3:49 pm

How to link to user profile, user posts, subscribed topics,

Post by Clare1234 » Fri Jul 05, 2013 3:56 pm

Hi,

I'd like to create links elsewhere on my site (not just the forum) and some links outside of the user's control panel that link to the user's profile, posts, subscribed topics, topics, and maybe some other things.

I also would like to figure out how to post links to log in and log out of the forum.

This has to be for any random user, and cannot have just one user's number in the url.

I already found on the internet that I can do this:

Code: Select all

<!-- IF not S_IS_BOT and S_USER_LOGGED_IN -->
<strong><a href="{ROOT_PATH}/memberlist.php?mode=viewprofile&un={S_USERNAME}">My Profile</a></strong>
<!-- ENDIF -->
This links to the user's profile. This type of link is exactly what I'm looking for. Does anyone know how to get those other links correct?

Thank you!!!!!!!!!!

Clare

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: How to link to user profile, user posts, subscribed topi

Post by EXreaction » Fri Jul 05, 2013 9:12 pm

Some of these are already defined in the page_header function.

Code: Select all

		'U_PRIVATEMSGS'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
		'U_RETURN_INBOX'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
		'U_POPUP_PM'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup'),
		'UA_POPUP_PM'			=> addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup')),
		'U_MEMBERLIST'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx"),
		'U_VIEWONLINE'			=> ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '',
		'U_LOGIN_LOGOUT'		=> $u_login_logout,
		'U_INDEX'				=> append_sid("{$phpbb_root_path}index.$phpEx"),
		'U_SEARCH'				=> append_sid("{$phpbb_root_path}search.$phpEx"),
		'U_SITE_HOME'			=> $config['site_home_url'],
		'U_REGISTER'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
		'U_PROFILE'				=> append_sid("{$phpbb_root_path}ucp.$phpEx"),
		'U_MODCP'				=> append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id),
		'U_FAQ'					=> append_sid("{$phpbb_root_path}faq.$phpEx"),
		'U_SEARCH_SELF'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
		'U_SEARCH_NEW'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
		'U_SEARCH_UNANSWERED'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'),
		'U_SEARCH_UNREAD'		=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
		'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'),
		'U_DELETE_COOKIES'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'),
		'U_TEAM'				=> ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'),
		'U_TERMS_USE'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
		'U_PRIVACY'				=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),
		'U_RESTORE_PERMISSIONS'	=> ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '',
		'U_FEED'				=> generate_board_url() . "/feed.$phpEx",
E.g.

Code: Select all

<a href="{U_SEARCH_SELF}">My posts</a>
For others, I'd recommend you add them to the page_header function and use append_sid so you know they'll always work (just copy another similar one and modify it as necessary).

Clare1234
Registered User
Posts: 4
Joined: Fri Jul 05, 2013 3:49 pm

Re: How to link to user profile, user posts, subscribed topi

Post by Clare1234 » Sat Jul 06, 2013 1:45 pm

Thank you EXreaction! That is working great!

I am using several of them. I am trying to figure out a few though. The 'U_SITE_HOME' and 'U_PROFILE' seem to both link to the user's profile.

How do I set 'U_REGISTER' to only be seen by people who are only logged out? And the others by people who are only logged in?

And is there one to show just the user's topics? And one to show subscribed topics? And one to mark all posts as read?

Thank you this worked really well. I really appreciate your help!!!!!!!!

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: How to link to user profile, user posts, subscribed topi

Post by EXreaction » Sat Jul 06, 2013 4:01 pm

Sorry, I copied that code from 3.1-dev, U_SITE_HOME isn't available in 3.0.

To see if they are logged in:

Code: Select all

<!-- IF S_USER_LOGGED_IN -->
stuff for logged in users
<!-- ELSE -->
stuff for not logged in users
<!-- ENDIF -->
I don't think any built in functionality exists to list all the topics started by a user.

You can add more easily, just edit that output in page_header and include these (and more you may want):

Code: Select all

'U_SUBSCRIPTIONS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=subscribed'),
'U_MARK_ALL_READ'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',

Clare1234
Registered User
Posts: 4
Joined: Fri Jul 05, 2013 3:49 pm

Re: How to link to user profile, user posts, subscribed topi

Post by Clare1234 » Sat Jul 06, 2013 7:56 pm

Hi Exreaction,

That worked great!!!!! I would like to find out if it is possible to link to those items from elsewhere in my website outside of the forum folder on the server. I am using WordPress, and I am trying to link to these things from a page in WordPress too. Is there a way to do that? phpBB3 is in a folder on the same server in the same domain as the WordPress site.

I have been using the links like this: <a href="{U_SEARCH_SELF}">My posts</a>

Thank you!!!!!!!!!!!!!!!

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: How to link to user profile, user posts, subscribed topi

Post by EXreaction » Sat Jul 06, 2013 8:22 pm

Outside of your phpBB folder you'll probably just want to make the links manually. Using append_sid or the template engine could require significant work (especially to use on Wordpress), which probably isn't worth the effort.

Clare1234
Registered User
Posts: 4
Joined: Fri Jul 05, 2013 3:49 pm

Re: How to link to user profile, user posts, subscribed topi

Post by Clare1234 » Sat Jul 06, 2013 9:13 pm

Thanks Exreaction,

How do you make the links manually? Like just link to the forum? I can do that, but if I can make the links manually to each of the user's items like their profile, posts, etc, then I will.

Please let me know which is possible.

Thank you so much!!!!!!!!!!!! :)

Clare

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: How to link to user profile, user posts, subscribed topi

Post by EXreaction » Sat Jul 06, 2013 10:56 pm

You should be able to link to just about everything for everyone by just by going to the page you want in your browser and copying the URL of the page.

You can test that the URL you grab is correct by logging out, logging in as a different user, then pasting the URL in your browser. If it goes to the correct page for that user also, it should work for everyone.

Locked

Return to “[3.0.x] MOD Writers Discussion”