How to auto generate WPCargo API Key after user registration

These guides cover:


To auto generate WPCargo API Key after user registration, you have to add this simple hook “user_register” to you theme functions.php file

</pre>
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );

function myplugin_registration_save( $user_id ) {
$wpcargo_api = get_user_meta( $user_id, 'wpcargo_api', true );
if( !$wpcargo_api && function_exists( 'wpcapi_generate_api_key' ) ){
$api_key = wpcapi_generate_api_key( );
update_user_meta( $user_id, 'wpcargo_api', $api_key );
}
}
<pre>

 

0
    0
    Your Cart
    Your cart is emptyReturn to Shop