WP User FrontEnd Pro does not allow one user to activate more than one free subscription pack, however for my purpose I need this feature disabled. I contacted weDevs and they gave me the section of code to manipulate but I'm not having any luck. Here was the response for anyone looking to do the same and for anyone that can help me:
"You have to customize payment.php which is located at “wp-content/plugins/wp-user-frontend/class” to get this feature. To be precise, you have edit the code block that is written for free packs and that is from line number 109 to 124."
Here is 109-124:
if ( $pack_id && $is_free ) {
$wpuf_subscription = WPUF_Subscription::init();
if ( ! WPUF_Subscription::has_used_free_pack( $current_user->ID, $pack_id) ) {
$wpuf_subscription->new_subscription( $current_user->ID, $pack_id, null, false, 'free' );
WPUF_Subscription::add_used_free_pack( $current_user->ID, $pack_id );
$message = apply_filters( 'wpuf_fp_activated_msg', __( 'Your free package has been activated. Enjoy!' ), 'wpuf' );
} else {
$message = apply_filters( 'wpuf_fp_activated_error', __( 'You already have activated a free package previously.' ), 'wpuf' );
}
?>
<div class="wpuf-info"><?php echo $message; ?></div>
<?php
Navjot Singh answers:
Try changing it into
if ( $pack_id && $is_free ) {
$wpuf_subscription = WPUF_Subscription::init();
$wpuf_subscription->new_subscription( $current_user->ID, $pack_id, null, false, 'free' );
WPUF_Subscription::add_used_free_pack( $current_user->ID, $pack_id );
$message = apply_filters( 'wpuf_fp_activated_msg', __( 'Your free package has been activated. Enjoy!' ), 'wpuf' );
?>
<div class="wpuf-info"><?php echo $message; ?></div>
<?php
Dbranes answers:
Instead of modifying the plugin itself and loosing the modifications each time you upgrade the plugin,
you could try this instead:
add_filter( 'get_user_metadata', 'wpq_get_user_metadata', 99, 4 );
function wpq_get_user_metadata( $value, $user_id, $meta_key, $single ){
if( 'wpuf_fp_used' === $meta_key && $single ) {
return '';
}
return $value;
}
in your <em>functions.php</em> file in your current theme directory or better yet as your own plugin.
Kyle answers:
Try this:
if ( $pack_id && $is_free ) {
$wpuf_subscription = WPUF_Subscription::init();
$wpuf_subscription->new_subscription( $current_user->ID, $pack_id, null, false, 'free' );
WPUF_Subscription::add_used_free_pack( $current_user->ID, $pack_id );
$message = apply_filters( 'wpuf_fp_activated_msg', __( 'Your free package has been activated. Enjoy!' ), 'wpuf' );
?>
<div class="wpuf-info"><?php echo $message; ?></div>
<?php
Kyle comments:
Try this:
if ( $pack_id && $is_free ) {
$wpuf_subscription = WPUF_Subscription::init();
$wpuf_subscription->new_subscription( $current_user->ID, $pack_id, null, false, 'free' );
WPUF_Subscription::add_used_free_pack( $current_user->ID, $pack_id );
$message = apply_filters( 'wpuf_fp_activated_msg', __( 'Your free package has been activated. Enjoy!' ), 'wpuf' );
?>
<div class="wpuf-info"><?php echo $message; ?></div>
<?php
Kyle comments:
Not sure why that posted twice, sorry bout that
Arnav Joy answers:
try this
<?php
if ( $pack_id && $is_free ) {
$wpuf_subscription = WPUF_Subscription::init();
$wpuf_subscription->new_subscription( $current_user->ID, $pack_id, null, false, 'free' );
WPUF_Subscription::add_used_free_pack( $current_user->ID, $pack_id );
$message = apply_filters( 'wpuf_fp_activated_msg', __( 'Your free package has been activated. Enjoy!' ), 'wpuf' );
?>
<div class="wpuf-info"><?php echo $message; ?></div>
<?php