This tutorial is an update of Dylanblitz' howto for older versions. Credits to him, and thanks for giving me green light for building on his ideas.
This has been tested with [S]4.1.4[/S] 4.2,[S] but should work as far back as 4.0.8, when profile customization was reintroduced. [/S]
[Explanation: At least with version 4.1.8, the template name convention for profile tabs was changed. If you want to code for an earlier version, use custom_profile_tab_test as template name.]
To create a new member profile tab, create a plugin at hook member_complete
Code:
if (isset($vbulletin->GPC['tab']))
{
$selected_tab = $vbulletin->GPC['tab'];
}
$blockinfo['title'] = "Test Title";
$blockid = "test";
$taburl = $memberurl = fetch_seo_url('member', $prepared) . "&tab=test#test";
$templater = vB_Template::create('memberinfo_tab');
$templater->register('selected_tab', $selected_tab);
$templater->register('relpath', $relpath);
$templater->register('blockinfo', $blockinfo);
$templater->register('blockid', $blockid);
$templater->register('taburl', $taburl);
$template_hook['profile_tabs_last'] .= $templater->render();
// ### Your code to fill the tab ###
// Don't forget you need to register any variables for use in templates
$test_tab_content = "Congratulations, you can see me, I'm your PHP Code!";
$templater = vB_Template::create('memberinfo_block_test');
$templater->register('selected_tab', $selected_tab);
$templater->register('test_tab_content', $test_tab_content);
$template_hook['profile_tabs'] .= $templater->render();
This code creates the tab and inserts it as the last tab in the row. You
should give the tab its own unique id. In this case, we use test. If you change it, make sure you do so everywhere in the plugin and in the template. It has to be identical everywhere
can add custom code to fill your tab, if the content is not static html. In that case you would only add code to the template.
have to register any variables you want to output in the template, if you add custom code. You will be able to call that variable by using {vb:var test_tab_content} in the template.
choose a name for the template you will be calling to show your tab's content. Note that template names are case sensitive: test is not the same as TEST or Test. Remember that in step 2!
Second step
The second step to a custom profile tab is to create a new template. It has to be the name you used in your php code to create it, in our case: memberinfo_block_test.
You would have to supply fields to everyone via the Admin CP -> User Profile Field Manager. You can make them optional so only users who want to fill them out have to- but they would all show under "About Me."
That is how I personally have it now. There isn't a way to then call on those profile fields to appear within the new tab?
I did the first step, and it showed in profile tabs. When I add the 2nd step and activate it, it gives this error:
Quote:
Parse error: syntax error, unexpected '<' in /home/bloggers/public_html/member.php(685) : eval()'d code on line 35
I didn't change id or anything.
What should be the title of both step? I set the 2nd one to "memberinfo_block_test" and 1st one to anything I want.
Both orders are 5 and hook locations are member_info
What did I do wrong?