Skip to content

Instantly share code, notes, and snippets.

@denisbaranov
Last active December 13, 2020 12:59
Show Gist options
  • Save denisbaranov/4b8890f60c35a7b03e3476bdb49b2f8b to your computer and use it in GitHub Desktop.
Save denisbaranov/4b8890f60c35a7b03e3476bdb49b2f8b to your computer and use it in GitHub Desktop.
This example shows how to add several tabs with custom shortcodes into the Profile page of the Ultimate Member.
<?php
/**
* This example shows how to add several tabs with custom shortcodes into the Profile page of the Ultimate Member.
* You can add custom code to the end of the file functions.php in the active theme directory.
* Important! Each tab must have a unique key.
*
* Ultimate Member documentation: https://docs.ultimatemember.com/
* Ultimate Member support (for customers): https://ultimatemember.com/support/ticket/
*/
/**
* Add new profile tabs
* @param array $tabs
* @return array
*/
function um_mycustomtab_add_tab( $tabs ) {
/* MY COURSES */
$tabs['ld_course_list'] = array(
'name' => 'MY COURSES',
'icon' => 'um-faicon-book',
'custom' => true
);
if ( !isset( UM()->options()->options['profile_tab_' . 'ld_course_list'] ) ) {
UM()->options()->update( 'profile_tab_' . 'ld_course_list', true );
}
/* MY CERTIFICATES */
$tabs['uo_learndash_certificates'] = array(
'name' => 'MY CERTIFICATES',
'icon' => 'um-faicon-certificate',
'custom' => true
);
if ( !isset( UM()->options()->options['profile_tab_' . 'uo_learndash_certificates'] ) ) {
UM()->options()->update( 'profile_tab_' . 'uo_learndash_certificates', true );
}
return $tabs;
}
add_filter( 'um_profile_tabs', 'um_mycustomtab_add_tab', 1000 );
/**
* Render the tab 'MY COURSES'
* @param array $args
*/
function um_profile_content_ld_course_list( $args ) {
echo do_shortcode( '[ld_course_list mycourses="true"]' );
}
add_action( 'um_profile_content_ld_course_list', 'um_profile_content_ld_course_list' );
/**
* Render the tab 'MY CERTIFICATES'
* @param array $args
*/
function um_profile_content_uo_learndash_certificates( $args ) {
echo do_shortcode( '[uo_learndash_certificates class="my-class" title="my-title"]' );
}
add_action( 'um_profile_content_uo_learndash_certificates', 'um_profile_content_uo_learndash_certificates' );
@luismiguelrosero
Copy link

Cordial greeting

Excuse me gentlemen, I KNOW very well that it is not your obligation, much less, but I really do not know what to do or who to turn to.

I am not a programmer, I am just a humble designer who has made a web page using the Ultimate Member plugin, because it is free (it is what is within the reach of my economy ...)

I see that you and several here in this thread, have had the need to create additional tabs for your users, well, me too, only I do not know anything about code and although it is very difficult for me to do so, I presume to understand after some time of effort and a lot of trial and error, but in the end I manage to understand.

I will tell you about my case to see if someone can guide me a little and give me a hand, specifically and at the risk of sounding a little daring, ask, with much respect and humility, for the lines of code that will help me solve the great problem that I am facing. now. (Believe me, I have done everything in the UM plugin developer documentation to the letter, but this does not give me a positive result.)

I have my website, I have UM, I have user registration enabled, so far, so good.

I have two user types with attribute level 2 (members only) (- * There are values ​​for 'default_privacy' attribute:

  • 0 - Anyone,
  • 1 - Guests only,
  • 2 - Members only,
  • 3 - Only the owner
  • / -)

And in turn those members or registered users of level 2 are: Employer and Employee.

---- I hope I have understood up to here ----

Using the sample code from the original plugin documentation
(https://docs.ultimatemember.com/article/69-how-do-i-add-my-extra-tabs-to-user-profiles)

I have managed to create an additional tab, I will actually need two, but I cannot get the first one to work properly.

What I'm looking for is that when a level two user enters the profile, they see ONLY the tab that corresponds to them, I explain a little more, as I already mentioned, I only have two types of registered users, Employer and Employee, well, what I seek to achieve is that if the employer user enters their profile in the new personalized tab, they can find an html

in their content where there will be a button that takes them or directs them to a form to request employees according to the needs and characteristics demanded, example : I request baker, Man, with a motorcycle ... and that this new tab is only shown to this level two user who has registered under the Employer profile.

But ----, eye, but, if the one who enters your profile is a level two user but of the Employee type, they will be shown, also 1 single tab, different from that of the employer, but in the same location, that is to say the tab next to the "information" tab that has UM by default, and that tab in its content also has an html

but with a button that takes you to a form to fill out, complete and send your resume.

tab 1, shows the content only to the user registered as an employer
tab 2, shows only the content to the user registered as an employee

Pdta. The forms I have already solved satisfactorily and each one I have on a different and independent page, on the one hand, a page for the employer form on the other hand, another page for the form of the person who is seeking employment or specifically the Employee.

To those who can help me, all that remains is to reiterate again and again and my gratitude and respect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment