Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › eMember – How to get the Redirect page
Tagged: member home page, Tweaks, wp membership
- This topic has 7 replies, 3 voices, and was last updated 11 years, 4 months ago by admin.
-
AuthorPosts
-
April 20, 2012 at 2:24 pm #6139lenrocMember
Hi,
I have the membership levels, each redirecting to the page containing the content for that member level… however in the membership menu I want to make that redirect url as the home for the user.
How do I get the redirect url from the membership the user belongs to, this might be a good snippet to add to the http://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248 page as well.
Thank you,
Cornel
April 21, 2012 at 5:07 am #44287adminKeymasterOkay added an example code snippet for the following:
Retrieve the redirect url (home page URL) from the membership level the user belongs to.
You can find the example at the following documentation page:
http://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248
July 20, 2013 at 4:08 pm #44288BjeddMemberHi, I see the tweak, but what I want to do is apply that particular function just to a url link so that when someone clicks that link they are redirected back to their home page based on their member level (level_id?). How do I specify this only to apply to a specific link e.g.- [a href=”?”]Home Page[/a] using the level_id?
$emember_auth = Emember_Auth::getInstance();
$user_id = $emember_auth->getUserInfo('member_id');
if (!empty($user_id))
{
//User is logged in so add your conditional code here
$membership_level_resultset = $emember_auth->userInfo->primary_membership_level;
$home_page_url = $membership_level_resultset->loginredirect_page;
//Do something with this URL
header('Location: $home_page_url');
}Thanks,
Bruce
July 21, 2013 at 12:16 am #44289adminKeymasterHi Bruce, The above code will automatically redirect the user to their home page (specified in their membership level) when it is executed. If you want them to click a link to go there then simply create the link like the following:
$emember_auth = Emember_Auth::getInstance();
$user_id = $emember_auth->getUserInfo('member_id');
if (!empty($user_id))
{
//User is logged in so add your conditional code here
$membership_level_resultset = $emember_auth->userInfo->primary_membership_level;
$home_page_url = $membership_level_resultset->loginredirect_page;
//Do something with this URL
echo '< a href="'.$home_page_url.'">Click here to go to your homepage</a>';
}July 22, 2013 at 4:12 pm #44290BjeddMemberThat works perfectly, but how can I get that custom php function into the WP admin sidebar or in the WP admin dashboard as a simple link?
July 22, 2013 at 11:59 pm #44291adminKeymasterYou can execute php code on the sidebar using a PHP code widget plugin. The following post has more info on how to add widgets to your sidebar that can execute php code:
July 25, 2013 at 3:35 pm #44292BjeddMemberThanks, I read the above thread, but that is not quite what I am asking. I am wanting to place this as a WP Admin link in the Admin sidebar, not a theme widget or sidebar. If not the WP Admin sidebar, at least somewhere prominent in the WP Admin dashboard or the WP Admin Toolbar. I know there are some plugins that can help, but they seem to be overkill for just this one function. I am trying to avoid another plugin if possible.
July 26, 2013 at 12:22 am #44293adminKeymasterI see what you mean, eMember doesn’t have an option to add some code in the admin dashboard. Your best option would be to execute this custom code via another plugin.
There is a common misconception about the number of plugins sometimes. Generally, it is good to use a minimal set of useful plugins only (less plugins usually mean you won’t have a lot of bloat on your site). However, if you are going to add 50 lines of code to your site then it doesn’t matter if those lines come from one plugin or 2 plugins. The load on the server is going to be the same because it is still executing those 50 lines of code.
Here is another example:
If you took all the code from say 15 of your plugins and put them in 1 plugin then you haven’t gained anything really. Your server is still executing the same amount of code.
Here is another good read:
http://www.tipsandtricks-hq.com/top-3-common-reasons-for-a-slow-wordpress-site-in-my-experience-4749
-
AuthorPosts
- You must be logged in to reply to this topic.