php - 引荐来源网址逻辑 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' );
我期待听到您的想法和建议。希望你能把我们推向正确的方向:-)
解决方案
推荐阅读
- node.js - 在发布请求时发出套接字
- python - 如何在 pandas DataFrame 中随机提取 n 个连续行?
- java - ViewLifeCycleOwner 在从 Main 到后台再到 MainThread 时返回 null
- java - 如何将二维数组转换为字符串
- android-studio - 更改组件的可见性时,BottomSheet 移动到屏幕顶部
- reactjs - 如何删除反应 dropzone 中的默认相机选项?
- python - 如何使用 pandas 在数据框中过滤和创建新列
- java - 如何 Java 将流多个条件从 int 数组映射到字符串数组
- spring-boot - 如何使用 Spring Data Rest 修补无存储库的项目资源集合
- google-cloud-functions - 如何在 Google Cloud Function 上的 Spring Cloud 函数中获取 Pub/Sub 事件的元数据