Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
945 B
5
Indexable
Never

global $salesking_public;
remove_action('woocommerce_account_dashboard', array($salesking_public, 'salesking_dashboard_button'), 10);
add_action('woocommerce_account_dashboard', 'salesking_dashboard_button2');
function salesking_dashboard_button2(){
    if (is_agent(get_current_user_id())){
        ?>
        <a class="salesking_go_to_agent_dashboard" href="<?php echo apply_filters('salesking_switch_back_link', trailingslashit(get_page_link(apply_filters( 'wpml_object_id', get_option( 'salesking_agents_page_setting', 'disabled' ), 'post' , true))).'customers'); ?>"><button class="salesking_go_to_agent_dashboard_button"><?php esc_html_e('Go to Sales Agent Dashboard', 'salesking'); ?></button></a>
        <?php
    }
}
function is_agent($user_id){
    $agent_group = get_user_meta($user_id,'salesking_group',true);
    if ($agent_group !== 'none' && !empty($agent_group)){
        return true;
    } else {
        return false;
    }
}
Leave a Comment