BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #19784

    Hello Brajesh,

    Its good. last time i had to go wrong in the times and wordpress roles. I will now put it on the production site
    Thank you for your great support 🙂
    Happy Holidays and I wish you the best in 2019
    Best regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18959

    Hello Brajesh,
    To understand each other, I did not retest what worked.
    1 After doing what you asked, I just clicked on the “set featured” button to members. The members stay all the time “set featured”!
    2 / I do not see where you support the xprofile

    https://pastebin.com/6C3ejJYL

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18866

    HI Brajesh,

    ok I put in my code in functions.php :

    
     if( $form_id==112 ) {
        bp_featured_members()->add_user($user_id);
        update_user_meta( $custom[3], '_paid_featured', 1 );
        update_user_meta( $custom[3], '_bpfm_featured_expiry_time', time() + bpfm_paypal_get_role_based_interval( $custom[3] ) );
      }
    

    and added in your plugin the mentioned code

    I clicked the button manually “set featured” and several hours after the member is still present
    How can this work according to the xprofile field or by clicking on your button manually to “highlight”?

    I’m sorry for the delay this week because I have 1 site for association that has been hacked, I am less available
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18819

    Hi Brajesh,
    that’s what I said in https://buddydev.com/support/forums/topic/paiement-with-featured-member/page/5/#post-18596

    The idea says otherwise if it’s not too difficult to have a different expiration time (also depends on the value of a field)
    a) if the administrator press the “set featured” button
    b) in the case of payment by paypal

    is that clearer ?
    Regards

    • This reply was modified 6 years ago by Hervé.
  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18799

    Hello Brajesh,
    It worked by testing on 2 members with different roles 🙂
    sorry, I thought I activated the plugin 🙁
    Only problem is that I have a 404 error systematically if I go to the http://wptest-am.88h.ovh/tableau-de-bord-membres/ page
    Can this be related to your program? because it worked well before!
    I do not have a message in the logs.
    I momentarily solve the problem by saving the permalinks again

    Not urgent, but as you have the memory now, do not hesitate if you can advance on the improvement of 2 desires
    (cf https://buddydev.com/support/forums/topic/paiement-with-featured-member/page/5/#post-18599)
    Thank you
    Hervé

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18682

    Hi Brajesh,

    I did 2 other tests. the members stay “set featured”
    I have many values ​​(cf phpmyadmin)
    I put that in your function and I refreshed the page regularly (normally it should work)
    Do you want admin access?
    Regards

    ***

    private function get_role_based_interval( $user_id ) {
    
    		$default = 10; // 10 days by default? A MODIF
    
    		$user = get_user_by( 'id', $user_id );
    		if ( empty( $user ) ) {
    			return $default * MINUTE_IN_SECONDS; //DAY_IN_SECONDS
    		}
    
    		$user_roles = $user->roles;
    
    		if ( empty( $user_roles ) ) {
    			return $default * MINUTE_IN_SECONDS; //DAY_IN_SECONDS
    		}
    
    		// Map role to days.
    		$map = array(
    			'membre0' => 2, // 60 days
    			'membre1'        => 3,
    			'author'        => 30,
    			'contributor'   => 20,
    			'subscriber'    => 5,
    		);
    
    		$allowed_days = 0; // 0 days.
    
    		// calculate the max allowed days.
    		foreach ( $user_roles as $role ) {
    			if ( isset( $map[ $role ] ) && $map[ $role ] > $allowed_days ) {
    				$allowed_days = $map[ $role ];
    			}
    		}
    
    		// if no user role has mapped value.
    		if ( ! $allowed_days ) {
    			$allowed_days = $default;
    		}
    
    		return $allowed_days * MINUTE_IN_SECONDS; //DAY_IN_SECONDS
  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18619

    Hi Brajesh,

    I replaced your code as you told me.
    I replaced by

    $map = array(
    			'membre0' => 1, // 60 days
    			'membre0'        => 1,
    			'author'        => 30,
    			'contributor'   => 20,
    			'subscriber'    => 5,
    		);
    

    See the complete file https://pastebin.com/naWV91sH
    “Set featured” was done after paypal payment
    At the end of the programmed time (1 day), it is not removed
    I do not have an error message except
    “PHP Warning: mysqli_real_connect (): (HY000 / 2002): Connection timed out in /home/xxx/-AM.88h.ovh/wp-includes/wp-db.php on line 1538”
    A priori not related to your code because appears before!
    An idea ?
    To speed up the resolution, I will want to do tests with short times.
    What is the minimum amount of time I can put? I know there is one but I do not remember which one.
    Can I put 0.1 days or 0.01 days?
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18596

    Hi Brajesh,

    1- Ok, Old code “Plugin Name: BuddyPress Featured Member Expirable Membership Addon” in https://pastebin.com/13kNA2x8

    I made a code that can not work.
    You say that only one thing can work!
    I do not know if it is possible (or not) to have a duration according to the field xprofile (“I am”) and / or (paypal paypal / your button “”

    I will retranslate* in non real code, the initial wish

    If no payment (OR press button “SET Featured”)
    If roleWp = member1 and xprofile (“Je suis”) = ‘Femme’ => duration 24 days
    If roleWp = member1 and xprofile (“Je suis”) = ‘Homme’ => duration 12 days
    If roleWp = member0 and xprofile (“Je suis”) = ‘Femme’ => duration 16 days
    If roleWp = member0 and xprofile (“Je suis”) = ‘Homme’ => duration 08 days
    If payment
    If roleWp = member1 and xprofile (“Je suis”) = ‘Femme’ => duration 40 days
    If roleWp = member1 and xprofile (“Je suis”) = ‘Homme’ => duration 20 days
    If roleWp = member0 and xprofile (“Je suis”) = ‘Femme’ => duration 30 days
    If roleWp = member0 and xprofile (“Je suis”) = ‘Homme’ => duration 15 days

    Regards

    * ************************************

    $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='0.04'; $varHD.='Attendu2: 0.04 ';}
                if ( ($jesuis=='Une femme') AND (in_array('membre0', $user_roles)) ){$nbr_jour_a_la_une='0.03'; $varHD.='Attendu2: 0.03 ';}
                if ( ($jesuis=='Un homme') AND (in_array('membre1', $user_roles))  ){$nbr_jour_a_la_une='0.02'; $varHD.='Attendu2: 0.02 ';}
                if ( ($jesuis=='Un homme') AND (in_array('membre0', $user_roles))  ){$nbr_jour_a_la_une='0.01'; $varHD.='Attendu2: 0.01 ';}
               
                update_user_meta( $user_id, '_paid_featured', 0 ); // remise à 0 meta disant que le membre ne paye plus , mis à 1 dans fonction si paiement
            }
            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')
            }
     
  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18589

    Hello Brajesh,

    I looked at your code.
    I want to know if I understood correctly.
    a) I put your file under plugins/bp-featured-member-expirable-membership-master/ instead of the old
    b) I put my wordpress token instead of author, editor … to have an expiration date based on the wordpress role (in private function get_role_based_interval( $user_id ) { …).

    I’m not sure I understand when you say:

    “I will be sharing a method of doing it based on member type.”

    “There, please feel free to change it.”

    My wish is to make a duration
    c) longer starring, for a member with xprofile_get_field_data ($ field_jesuis, $ user_id) = “Une femme”
    If not possible to differentiate. The time would multiply by a factor (eg: 1.5)
    c) shorter if it is me who presses manually the button “SET Featured”
    The time would be multiply by a factor (e.g: 0,5)

    Is it impossible or too difficult to do?
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: [Resolved] paiement with featured Member #18526

    Hello Brajesh,
    Must I answer my interest?
    Good day
    Regards