BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #45023

    OMG , thank you Brajesh :))

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #45011

    Hello Brajesh,

    Thank you for your response.
    I was speaking about filtering the title of the Who’s Online Buddypress widget and i’ve noticed that it’s offering a ‘widget_title’ filter. My code is filtering the title but for some reason it affects also some other widgets.

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #45005

    Hello Brajesh,

    Thank you so much for your help.
    It works correct now.

    One last question.

    I need to filter the title of the widget but it seems that i am doing something wrong with my code

    add_filter( 'widget_title','enostalgia_show_online_members_only_widget_title', 10, 3 );
    function show_online_members_only_widget_title( $title, $settings, $id_base ) {
    
        if ( 'Ποιος είναι συνδεδεμένος' == $title ) 
        return '<p class="notranslate stay-in-touch" style="color: #b8860b;">WHO IS ONLINE IN OUR FORUM</p>';
    }

    because it removes titles from other widgets also.

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44105

    Hello Ravi,

    Thank you very much for your patience and support. You are truly remarkable. Now it works correct.

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44097

    Hello Ravi,

    Thank you very much for your feedback.Your code is giving the appropriate results. However the problem with this logic is that when user is checking $is_selected_food && $is_selected_movies the output is FOOD, MOVIE, FOOD & MOVIES. Actually it outputs all the 3 true cases :

    $is_selected_movies MOVIE
    $is_selected_food FOOD
    $is_selected_food && $is_selected_movies FOOD & MOVIES

    I have used only if statements inside my wp_mail.
    if ( empty( $data ) ) { // some html}
    if ( $is_selected_movies ) {// some other html}`
    if ( $is_selected_food ) { // some other html} and so on…

    If i set elseif, then i dont get correct results.

    If $is_selected_food && $is_selected_movies should be only this true.

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44075

    Hello Ravi,

    Thank you very much for your feedback.
    Your code works perfect and gives the results you mentioned. However what i need is:

    // If all three options are selected.
    TEXT WILL BE SEND

    // If option Music and option Food are selected.
    TEXT WILL BE SEND

    // If option Music and option Movie are selected.
    TEXT WILL BE SEND

    // If option Movie and option Food are selected.
    TEXT WILL BE SEND

    // If only option Movie is selected.
    TEXT WILL BE SEND

    // If only option Food is selected.
    TEXT WILL BE SEND

    // If only option Music is selected.
    TEXT WILL BE SEND

    The text is irrelevant to the conditions programmatically and dont need to fetch the array $data inside the $message . Just need the conditions for every option of the user.

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44042

    Hello Ravi,

    Thank you so much for your help 🙂

    I am sorry if i confused you. The $message information is not related with the $data. Its just an introduction message text, and i don’t really need data from the $data . The text ‘Food is selected’ was just an example. I just need to pass the if statements for each users choice so that i can send with wp_mail the appropriate text accordingly.

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44031

    Hello Ravi,

    Let me explain i bit better what i actually need to do 🙂 On BP registration page i have a checkbox that users can check if they wish (optional field and not required).

    Along with his checkbox preference i am sending a welcome email to the user.

    Something like

    function send_welcome_email_to_new_user($user_id) {
    
    		$data = xprofile_get_field_data( 12, $user_id );
    
           
    		$message = sprintf( 'Hello' ) . "<br>"; 
    		if ( statements ) ) {
            $message .= sprintf( 'Music is selected' ) ."<br><br>";
             } elseif ( statements ) ) {
            $message .= sprintf( 'Food is selected' ) ."<br><br>";
             }elseif ( statements ) ) {
            $message .= sprintf( 'Food and music are selected' ) ."<br><br>";
             }
    		
    		
    		
    		$headers = array('Content-Type: text/html; charset=UTF-8'); 
            
            wp_mail($to, $subject, $message,$headers);
            
    		
    
    }
    	
    			
    			add_action( 'bp_core_activated_user', 'send_welcome_email_to_new_user');

    So actually i need the structure that we have been speaking about before 🙂

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44016

    Hello Ravi, thank you for your help 🙂 This is what happens with elseif statements:

    $data = xprofile_get_field_data( 12, 23, ‘comma’);
    
    if ( ! $data ) { echo "No item is selected";}
    
    elseif ( in_array( ‘Music’, $data ) ) { echo "Music is selected";} -> outputs: Music is selected
    
    elseif ( ! array_diff( array( 'Music', 'Movies' ), $data ) ) { echo "Music and Movies are selected";} -> outputs: Music is selected (should output: Music and Movies are selected )
    
    elseif ( ! array_diff( array( 'Music', 'Movies', 'Food' ), $data ) ) { echo "All are selected";}

    -> outputs: Movies is selected (should output: All are selected )

    I will need to have only one output result according to users checks.

    With the previous code with only if statements , i was getting as an output for example:

    if ( ! array_diff( array( 'Music', 'Movies', 'Food' ), $data ) ) { echo "All are selected";}

    -> outputs: Music Movies Food Music is selected Food is selected Movies is selected Music and Movies are selected Music and Food are selected…. (because it was outputting all the if's. Should just output: All are selected )

    I hope this helps

    Regards Lefteris

  • Participant
    Level: Enlightened
    Posts: 36
    Lefteris on #44012

    Hello Ravi,

    Now it works, but there is one problem. The output is giving me results for each if that is true.

    So i have tried to set elseif because i would like only one output according to users checks. With elseif i get correct results only for this type of statements.

    if ( in_array( ‘Music’, $data ) ) { // Music is selected.}

    For array_diff statements i get wrong results.

    Regards Lefteris