我试图在另一个函数中使用一个函数,但我不想编辑核心文件,因此我试图添加带有挂钩的函数,但无法确定如何发送id。
下面您可以看到我是如何做到的,但我正在核心文件中调用我的函数。
这是核心文件中的函数:(我手动添加了我的函数create_submerchant ($_GET[ \'user_id\' ]);
使用该用户的ID)
public function user_row_actions_commit()
{
if ( !empty( $_GET[ \'action\' ] ) && !empty( $_GET[ \'user_id\' ] ) ) {
$wp_user_object = new WP_User( (int) $_GET[ \'user_id\' ] );
switch ( $_GET[ \'action\' ] ) {
case \'approve_vendor\':
$role = \'vendor\';
add_action( \'admin_notices\', array( $this, \'approved\' ) );
do_action( \'wcvendors_approve_vendor\', $wp_user_object );
create_submerchant ($_GET[ \'user_id\' ]);
break;
case \'deny_vendor\':
$role = \'customer\';
add_action( \'admin_notices\', array( $this, \'denied\' ) );
do_action( \'wcvendors_deny_vendor\', $wp_user_object );
break;
default:
// code...
break;
}
$wp_user_object->set_role( $role );
}
}
我的自定义功能:
function create_submerchant($user_id) {
$user_info = get_userdata($user_id);
$store_country = \'TR\';
$store_name = $user_info ->pv_shop_name;
$store_owner_name = $user_info ->_wcv_custom_settings_bankahesapadi;
$store_owner_lastname = $user_info ->_wcv_custom_settings_bankahesapsoyadi;
$store_email = $user_info -> user_email;
$store_address = $user_info ->_wcv_custom_settings_banka_adres;
$store_iban = $user_info ->_wcv_custom_settings_bankaiban;
$store_owner_id = $user_id;
$store_owner_tc = $user_info ->_wcv_custom_settings_kimlikno;
create_personal_sub_merchant($store_country,$store_name,$store_owner_name,$store_owner_lastname,$store_email,$store_address,$store_iban,$store_owner_id,$store_owner_tc);
}
那么,如何使用挂钩来实现这一点呢?