mardi 20 février 2018

Custom profile tab available only for current user

PLUGIN: WP USER MANAGER

so I’ve created custom tab with profile editing & password reset to minimize number of pages on my website and to make profile page of current user more slick.

Custom tab works fine, but I’ve got a little bit of a problem when trying to make my custom tab accesible only for the profile owner, so when someone visits someone else’s profile they don’t see the Actions tab.

function wpum_my_new_tab( $tabs ) {

        $tabs['custom'] = array(
            'id'       => 'profile_custom',
            'title'    => 'Actions',
            'slug'     => 'actions',
        );

        return $tabs;
}

function wpum_my_tab_content( $user_data, $tabs, $current_tab_slug ) {
    echo do_shortcode('[INSERT_ELEMENTOR id="193"]');
}

function showtabforcuuser ( $user_data ) {

    if( $user_data->ID == get_current_user_id() )
     {  
        add_filter( 'wpum_get_user_profile_tabs', 'wpum_my_new_tab' );
        add_action( 'wpum_profile_tab_content_custom', 'wpum_my_tab_content', 10, 3 );
     }
}

This code hides the ‘Actions’ tab but also the owner can’t see it.

Any suggestions?

Best regards, Christopher




Aucun commentaire:

Enregistrer un commentaire