• Resolved gjyshi

    (@gjyshi)


    I was doing this on buddy press using bp_is_my_profile() but I changed my site to Ultimate member because of some cpu issues.

    I#m trying to add an upload form using custom profile tab functions given in your docs.

    function um_profile_upload_tab_my_profile_only() {
    $user_id = um_profile_id();
    if ( is_user_logged_in() && um_fetch_user( $user_id ) ) {
    add_action( 'um_profile_content_upload_tab_default', 'um_profile_content_upload_tab_default' );
    add_filter( 'um_profile_tabs', 'um_upload_tab_add_tab', 1000 );
    }
    }
    add_action('init', 'um_profile_upload_tab_my_profile_only');

    This code does not show me the tab but when I use only is_user_logged_in() I get my custom tab on all profiles but I want to make it visible only as a part of my profile if I’m logged in.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter gjyshi

    (@gjyshi)

    $current_user_id = get_current_user_id();
    if ( is_user_logged_in() && $current_user_id ) {

    is also showing the form when I explore other profiles

    Plugin Support andrewshu

    (@andrewshu)

    Hello @gjyshi

    If I understood you corretlu try to change to this:

    if ( is_user_logged_in() && $current_user_id === $user_id )

    Regards.

    Thread Starter gjyshi

    (@gjyshi)

    it does the same I see custom tab button on other profiles too

    • This reply was modified 1 year ago by gjyshi.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @gjyshi

    Do you see it when you log in as this user? Do you need to add this tab only for one user on the whole site?

    Regards.

    Thread Starter gjyshi

    (@gjyshi)

    No, I don’t see it .

    As I said in my question before I was using buddypress with the bp_is_my_profile() so is there any alternative for UM which does he same job?

    My custom tab has a short code that allows users to post WordPress posts from their profile. When Im logged in as USER1 I go to my profile page using um_user_profile_url() but when I search users directory If I go to the USER2′s profile I don’t want too see the custom tab.

    This is my last try:

    global $current_user;
    $user_id = um_profile_id();
    $current_user_id = wp_get_current_user();
    if ( is_user_logged_in() && $current_user_id === $user_id ) {

    In fact the code looks fine but I don′t know why its hiding the custom tab also for the logged user USER1

    I am so sorry my English is so so.

    • This reply was modified 1 year ago by gjyshi.
    • This reply was modified 1 year ago by gjyshi.
    Thread Starter gjyshi

    (@gjyshi)

    I just tried to create a new function:

    function is_my_profile() {
    global $current_user;
    $user_id = um_profile_id();
    $current_user_id = get_current_user_id();
    if ( is_user_logged_in() && $current_user_id === $user_id ) {
    $my_profile = true;
    } else {
    $my_profile = false;
    }
    return apply_filters( 'is_my_profile', $my_profile );
    }

    and in my previous function which adds custom tab with content I tried:

    if ( is_user_logged_in() && is_my_profile() ) {

    No Luck.

    • This reply was modified 1 year ago by gjyshi.
    missveronica

    (@missveronicatv)

    @gjyshi

    Make the custom profile tab and use the UM settings for the display only for profile owner:

    https://docs.ultimatemember.com/article/1547-profile-tabs-setup#profile-menu

    Thread Starter gjyshi

    (@gjyshi)

    Thank you its nice to see this in options, so we can say that um_is_profile_owner() is an alternative of bp_is_my_profile() in BuddyPress ??

    Thank you for your help.

    Thread Starter gjyshi

    (@gjyshi)

    Sorry again just a last question please when you have time

    Can we make this option already selected via php? for example:

    function um_upload_tab_add_tab( $tabs ) {
    $tabs[ 'upload_tab' ] = array(
    'name' => 'Upload',
    'icon' => 'um-faicon-upload',
    'custom' => true,
    );
    UM()->options()->options[ 'profile_tab_' . 'upload_tab' ] = true;
    return $tabs;
    }

    I see );
    UM()->options()->options[ 'profile_tab_' . 'upload_tab' ] = true;
    maybe a trick can help us doing this preselected for the profile owner via a php function?

    • This reply was modified 1 year ago by gjyshi.
    missveronica

    (@missveronicatv)

    @gjyshi

    You can use this code snippet

    function um_upload_tab_add_tab( $tabs ) {
    
        $tabs[ 'upload_tab' ] = array(
                                    'name' => 'Upload',
                                    'icon' => 'um-faicon-upload',
                                    'custom' => true,
                                    );
        return $tabs;
    }
    add_filter( 'um_profile_tabs', 'um_upload_tab_add_tab', 10, 1 );

    with the UM settings for the privacy https://imgur.com/a/9s0rafP

    Thread Starter gjyshi

    (@gjyshi)

    Thank you

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Custom Tab for the logged in user’ is closed to new replies.