首页 > 解决方案 > 引荐来源网址逻辑 Wordpress

问题描述

我们在 Wordpress 中有一个引荐来源网址逻辑,它看起来像https://example.com/?ref=userid. 我们正在尝试将其切换为类似https://example.com/ref/userid. 我们现在使用的代码是:

// Ref Button
function func_register_button( $atts ) {

    if(isset($_GET['ref']) && is_valid_username($_GET['ref'])){
        $enter_link = 'https://example.com/sponsor/' . $_GET['ref'];
    }else{
        $enter_link = 'https://example.com/sign-up';
    }


    $a = shortcode_atts( array(
        'text' => __('Yes, I want to join now')
    ), $atts );

    $btn = '<a class="cta-btn" href="' . $enter_link . '" target="_blank">' . $a['text'] . '</a>';

    return $btn;

}
add_shortcode( 'register_button', 'func_register_button' );

我期待听到您的想法和建议。希望你能把我们推向正确的方向:-)

标签: phpwordpressref

解决方案


推荐阅读