BuddyDev

Search

[Resolved] paiement with featured Member

  • Keymaster
    (BuddyDev Team)
    Posts: 24512
    Brajesh Singh on #17132

    Hi Herve,
    Thank you.

    1. You can not use get_current_user_id() as it returns currently logged in user. It is not the cas e with IPN reply, so it won’t return anything.

    2. About using absint($custom[5]), I am not sure what it is as it is very specific to the plugin. Please ask plugin developer how to get the user id of the subscriber and you can use that.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #17189

    Hi Brajesh,
    The other developer finally gave me good value back $custom[3].

    Is there a test value (ex .: isBtnFeatured ()) to know if the “featured Member” comes from clicking on the “set featured” button?
    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24512
    Brajesh Singh on #17197

    Hi Herve,
    That’s good to know.

    Featured Members does not store how the member was featured. All it stores is whether a member is featured or not?

    You can add user meta when marking a user as featured using

    
    update_user_meta( $custom[3], '_paid_featured', 1 );
    
    

    It will save in user meta an extra value when featuring a member. You will need to remove it too when a member is removed from the featured list.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #17229

    Hello Brajesh
    Great, it works 🙂
    Thank you
    Regards
    ps: is it possible to see the meta_user (in a plugin) without programming?

  • Keymaster
    (BuddyDev Team)
    Posts: 24512
    Brajesh Singh on #17243

    You are welcome. I am Glad it worked.

    can you please explain me the last part

    
     is it possible to see the meta_user (in a plugin) without programming?
    

    I mean, we can show it with a few lines of code to the place where it is required but I am not sure how can we do it without any code.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #17267

    Hello Brajesh

    I will try to explain better!
    Overall it works.
    After payment a member is deactivated after a time.
    I wanted to improve the code by varying the connection time according to criteria
    My problem is that I try to test the different cases and it is very long. I found it interesting to use debug.log to see variables including meta_user. Maybe still improve by sending me an email on

    
    private function get_interval() {	
    		$nbr_jour_a_la_une='0';		
    		$field_jesuis = '23'; //57		
    		
    		$user_id = bp_loggedin_user_id();
    		$jesuis = xprofile_get_field_data($field_jesuis,$user_id ); 
    		$user_info = get_userdata($user_id);
    		$user_roles = isset($user_info->roles)?$user_info->roles:array();				
    		$meta_paie = get_user_meta( $user_id, _paid_featured , true); 		
    		
    		if ($meta_paie=='1'){ // utilisateur payant
    			if ( ($jesuis=='Une femme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='8'; 	} 
    			if ( ($jesuis=='Une femme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='7'; 	} 
    			if ( ($jesuis=='Un homme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='6'; 	} 
    			if ( ($jesuis=='Un homme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='5'; 	} 
    		}
    		else {
    			if ( ($jesuis=='Une femme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='4'; 	} 
    			if ( ($jesuis=='Une femme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='3'; 	}
    			if ( ($jesuis=='Un homme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='2'; 	} 
    			if ( ($jesuis=='Un homme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='1'; 	} 
    		}
    		
    		$varHD.= "user_id: ".$user_id;		
    		$varHD.= "<br>jesuis: " .$jesuis;	
    		$varHD.= "<br>meta_paie: " .$meta_paie;	
       	error_log ("APRES DESACTIV.". $varHD);		
    		return  $nbr_jour_a_la_une * DAY_IN_SECONDS; // 1 jour		
    	}
    

    In order to see if the removal of the highlight is functional, I made a function

    
    add_action('get_header', 'determine_temps_mise_en_avant');  
    function determine_temps_mise_en_avant() {
    	if (is_page(26) AND is_user_logged_in()) { 
    		$user_id = bp_loggedin_user_id();
    		$field_jesuis = '23'; //57		
    		$jesuis = xprofile_get_field_data($field_jesuis,$user_id ); //  $user_id );
    		$user_info = get_userdata($user_id);
    		$user_roles = isset($user_info->roles)?$user_info->roles:array();		
    		$varHD.= "user_id: ".$user_id;		
    		$varHD.= "<br>jesuis: " .$jesuis;		
    		$meta_paie = get_user_meta( $user_id, _paid_featured , true); 
    		$varHD.= "<br>meta_paie: " .$meta_paie;	
    		$nbr_jour_a_la_une='00';
    		if ($meta_paie=='1'){ // utilisateur payant
    			if ( ($jesuis=='Une femme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='8'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Une femme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='7'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Un homme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='6'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Un homme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='5'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    		}
    		else {
    			if ( ($jesuis=='Une femme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='4'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Une femme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='3'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Un homme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='2'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    			if ( ($jesuis=='Un homme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='1'; 	} // si membre de base ET une femme $user->has_cap('membre0')
    		}
    		
    		
    		$varHD.= "<br>nbr_jour_a_la_une: " .$nbr_jour_a_la_une;
      // echo $varHD;
      	error_log ($varHD);
       }
    }
    

    In debug.log, I see 2 things.
    after deactivation, I did not contain in my variables

    
    [12-Sep-2018 09:04:58 UTC] APRES DESACTIV.user_id: 0<br>jesuis: <br>meta_paie: 
    

    after refreshing the page, I still have _paid. This one may not have been disabled by !!

    
    [12-Sep-2018 09:04:58 UTC] AttenduTableau: 
      		user_id: 3<br>jesuis: Un homme<br>meta_paie: 1<br>nbr_jour_a_la_une: 6
    

    I hope it helps
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #17411

    Hello Brajesh
    Have you seen a solution to recover the settings in your function
    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24512
    Brajesh Singh on #17416

    Hi Herve,

    I am sorry but I do not understand the remaining problem.

    You mentioned that the code is working and adding featured members. What do you want to recover?

    
    $meta_value = get_user_meta( $user_id, "your_meta_key" , true); 		
    		
    

    Replace “your_meta_key” with the actual key and you will get the value.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #17421

    Hi
    The addition is working well now.
    I am now trying to make the setting in your function function get_interval ()

    As the cases are spread over several days. I have a function (determine_temps_mise_en_avant) to see in debug.log if _paid_featured has changed in value.
    By visiting the page where the widget is located, I execute my function and I see the value of _paid. It seems to me that it’s good

    I would like in your get_interval function that I also record _paid_featured and other variables in debug.log Out of it’s empty
    I think in your function I do not yet have to get the good value user_id

    
    private function get_interval() {	
    ...
    $user_id = bp_loggedin_user_id();
    $jesuis = xprofile_get_field_data($field_jesuis,$user_id ); 
    $user_info = get_userdata($user_id);
    $meta_paie = get_user_meta( $user_id, _paid_featured , true); 		
    		
    if ($meta_paie=='1'){
    ...
    error_log ("APRES DESACTIV.". $varHD);	
    return  $nbr_jour_a_la_une * DAY_IN_SECONDS;
    ...
    

    Outside this is not the case. I think in your function I do not yet have to get the good value user_id
    [12-Sep-2018 09:04:58 UTC] APRES DESACTIV.user_id: 0!!!<br>jesuis: ??? <br>meta_paie: ???

    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24512
    Brajesh Singh on #17438

    Hi Herve,
    You should not try accessing it in get_interval() that method does not deal with a user.

    If you want to fetch all user’s which have this custom meta key in the get_interval() that will be a different thing.

    Do you want to change interval per user? I don’t think that is needed to be done in get_interval().

The topic ‘ [Resolved] paiement with featured Member’ is closed to new replies.

This topic is: resolved