Forum Replies Created

Viewing 15 replies - 1 through 15 (of 93 total)
  • Thread Starter melchi2

    (@melchi2)

    function um_080822_email_notifications( $notifications ){
    
    	$notifications['um_greet_todays_birthdays'] = array(
    		'key'           	=> 'um_greet_todays_birthdays',
    		'title'         	=> __( 'Joyeux anniversaire!','um-groups' ),
    		'subject'       	=> 'Joyeux anniversaire de {site_name}',
    		'body'          	=> 'Bonjour {display_name},<br /><br />'.
    		                   'Nous te souhaitons un joyeux anniversaire!',
    		'description'   	=> __('Whether to send the user an email when someone\'s todays birthday.','um-member'),
    		'recipient'   	 	=> 'member',
    		'default_active' 	=> true
    	);
    
    	return $notifications;
    }
    add_filter( 'um_email_notifications', 'um_080822_email_notifications', 10, 1 );
    
    function um_080822_cron_task_birthday_greet_notification(){
    
        $date = date("/m/d");
    
        $query_args['meta_query'][ ] = array(
            'relation' => 'AND',
            array(
                'key' => 'birth_date_45_31',
                'value' => $date,
                'compare' => 'RLIKE'
            ),
            array(
                'key' => 'um_birthday_greeted_' . md5( $date ),
                'compare' => 'NOT EXISTS'
            )
        );
    
        $users = new WP_User_Query( $query_args );
    
        // Get the results
        $celebrants = $wp_user_query->get_results();
        
        // Check for results
        if ( !empty( $celebrants ) ) {
    
            foreach( $celebrants as $c ){
                $recipient_email = $c->user_email;
    
                $display_name = um_user("display_name");
                
                UM()->mail()->send( $recipient_email, 'um_greet_todays_birthdays', array(
                            'plain_text'	 => 1,
                            'tags'				 => array(
                                '{display_name}',
                            ),
                            'tags_replace' => array(
                                $display_name,
                            )
                ) );
                
    
                update_user_meta( $c->ID, 'um_birthday_greeted_' . md5( $date ), true );
            }
    
        }
    }
    add_action("um_do2_birthday_greet_notification","um_080822_cron_task_birthday_greet_notification");
    
    if ( ! wp_next_scheduled ( 'um_do2_birthday_greet_notification') ) {
        wp_schedule_event( time(), 'hourly', 'um_do2_birthday_greet_notification' );
    }

    I tried with the script but unfortunately it doesn’t work. In the database the date of birth is in this form birth_date_45_31 1984/11/22. I don’t understand what is blocking

    Thread Starter melchi2

    (@melchi2)

    Hello, I am sending you the script that allows the sponsor to receive an email when registering the godchild, to visit his file and to check the sponsor’s email during registration.<font _mstmutation=”1″ _msthash=”1047670″></font>

    add_action( 'um_custom_field_validation_email_parrain', 'um_custom_validate_email_parrain', 999, 3 );
    function um_custom_validate_email_parrain( $key, $array, $args ) {
        if ( $key == 'email_parrain' && isset( $args['email_parrain'] ) ) {
            if ( isset( UM()->form()->errors['email_parrain'] ) ) {
                unset( UM()->form()->errors['email_parrain'] );
            }
            if ( ! is_email( $args['email_parrain'] ) ) {
                UM()->form()->add_error( 'email_parrain', __( 'L’adresse e-mail du parrain que vous avez saisie n’est pas valide', 'membre-ultime' ) );
            } elseif ( ! email_exists( $args['email_parrain'] ) ) {
                UM()->form()->add_error( 'email_parrain', __( 'L’adresse e-mail du parrain que vous avez saisie n\'existe pas dans les comptes des membres.', 'membre-ultime' ) );
            }
        }
    }
    
    
    /**
     * Set custom email notification template and setting
     */
    function um_custom_validate_account( $notifications ){
    
        $notifications['um_custom_validate_account'] = array(
            'key'           	=> 'um_custom_validate_account',
            'title'         	=> __( 'Send Email for Sponsors Validation','ultimate-member' ),
            'subject'       	=> '{site_name} - Someone you have sponsored on the site needs to attention',
            'body'          	=> 'Hi,<br /><br />'.
                               'You have sponsored "{profile_name}" on the site.<br /><br />'.
                               'To view profile, please click the following link: {profile_link}',
            'description'   	=> __('Whether to send the sponsor an email when someone registered has sponsored with.','ultimate-member'),
            'recipient'   	 	=> 'admin',
            'default_active' 	=> true
        );
    
        return $notifications;
    }
    add_filter( 'um_email_notifications', 'um_custom_validate_account', 10, 1 );
    
    /**
     * Send email notification to the sponsor
     */
    function um_notify_sponsors( $user_id ){
        um_fetch_user( $user_id ); 
        $sponsor_email = um_user("email_parrain");
        if (!filter_var($sponsor_email, FILTER_VALIDATE_EMAIL)) {
            // Afficher un message d'erreur
            UM()->notifications()->add( 'SponsorInvalidEmail', 'L\'adresse e-mail du parrain n\'est pas valide.' );
            return;
        }
    
        if ( ! email_exists( $sponsor_email ) ) {
            // Afficher un message d'erreur
            UM()->notifications()->add( 'SponsorNotExist', 'L\'adresse e-mail du parrain n\'existe pas dans les comptes des membres.' );
            return;
        }
        // code pour envoyer la notification
        $sponsor_recipient = $sponsor_email;
        $profile_name = um_user("display_name");
        $profile_link = '<a href="' . um_user_profile_url( $user_id ) . '">' . um_user_profile_url( $user_id ) . '</a>';
    
        UM()->mail()->send( $sponsor_recipient, 'um_custom_validate_account', array(
                    'plain_text'	 => 1,
                    'tags'				 => array(
                        '{profile_name}',
                        '{profile_link}',
                    ),
                    'tags_replace' => array(
                        $profile_name,
                        $profile_link,
                    )
        ) );
    
    }
    add_action("um_after_save_registration_details","um_notify_sponsors",10, 2);
    
    
    Thread Starter melchi2

    (@melchi2)

    Thank you, I had found in the meantime and I had forgotten to close this topic, I apologize? I was sure I did, I’ll do an overview of all my messages for the closed if I found a solution

    Thread Starter melchi2

    (@melchi2)

    I found a better solution a notification when a new article is created and visible to all
    
    add_filter( 'um_notifications_core_log_types', 'add_new_article_notification_type', 200 );
    function add_new_article_notification_type( $array ) {
        $array['new_article'] = array(
            'title' => 'Nouvel article publié',
            'template' => 'Un nouvel article intitulé "{article_title}" a été publié par {member}.',
            'account_desc' => 'Quand un nouvel article est publié sur le site',
        );
    
        return $array;
    }
    
    add_filter( 'um_notifications_get_icon', 'add_new_article_notification_icon', 10, 2 );
    function add_new_article_notification_icon( $output, $type ) {
        if ( $type == 'new_article' ) {
            $output = '<i class="um-icon-article" style="color: #336699"></i>';
        }
    
        return $output;
    }
    
    add_action( 'publish_post', 'send_new_article_notification', 10, 2 );
    function send_new_article_notification( $ID, $post ) {
        $author_id = $post->post_author;
        $title = $post->post_title;
        $permalink = get_permalink( $ID );
    
        um_fetch_user( $author_id );
        $author_name = um_user( 'display_name' );
    
        $vars = array(
            'article_title' => $title,
            'member' => $author_name,
            'notification_uri' => $permalink,
        );
    
        // Envoyer une notification à tous les utilisateurs du site
        $users = get_users();
        foreach ( $users as $user ) {
            UM()->Notifications_API()->api()->store_notification( $user->ID, 'new_article', $vars );
        }
    }
    
    Thread Starter melchi2

    (@melchi2)

    <font _mstmutation=”1″ _msthash=”881764″></font>

    Here is the final script that works

    /**

      * Set custom email notification template and setting

      */

     function um_custom_validate_account( $notifications ){

    $notifications[‘um_custom_validate_account’] = array(

    ‘key’           => ‘um_custom_validate_account’,

    ‘title’         => __( ‘Send Email for Sponsors Validation’,’ultimate-member’ ),

    ‘subject’       => ‘{site_name} – Someone you have sponsored on the site needs to attention’,

    ‘body’          => ‘Hi,<br /><br />’.

                      ‘You have sponsored “{profile_name}” on the site.<br /><br />’.

                      ‘To view profile, please click the following link: {profile_link}’,

    ‘description’   => __(‘Whether to send the sponsor an email when someone registered has sponsored with.’,’ultimate-member’),

    ‘recipient’   => ‘admin’,

    ‘default_active’ => true

    );

    return $notifications;

    }

    add_filter( ‘um_email_notifications’, ‘um_custom_validate_account’, 10, 1 );

    /**

     * Send email notification to the sponsor

     */

    function um_notify_sponsors( $user_id ){

        um_fetch_user( $user_id ); 

        $sponsor_recipient = um_user(“email_parrain”);

    $profile_name = um_user(“display_name”);

    $profile_link = ‘<a href=”‘ . um_user_profile_url( $user_id ) . ‘”>’ . um_user_profile_url( $user_id ) . ‘</a>’;

    UM()->mail()->send( $sponsor_recipient, ‘um_custom_validate_account’, array(

    ‘plain_text’ => 1,

    ‘tags’ => array(

    ‘{profile_name}’,

    ‘{profile_link}’,

    ),

    ‘tags_replace’ => array(

    $profile_name,

    $profile_link,

    )

    ) );

    }

    add_action(“um_after_save_registration_details”,”um_notify_sponsors”,10, 2);

    Thread Starter melchi2

    (@melchi2)

    Hello Veronica,

    Sorry I thought I sent my message in English, sorry

    Thread Starter melchi2

    (@melchi2)

    Hello, I’m reassured, I thought it was me who had searched badly. I’ll see how to set it up. Thank you for everything, I put the ticket in solved<font _mstmutation=”1″ _msthash=”1015495″>

    Thread Starter melchi2

    (@melchi2)

    <font _mstmutation=”1″ _msthash=”991094″>

    /**

    • Set custom email notification template and setting
      */
      function um_custom_validate_account( $notifications ){ $notifications[‘um_custom_validate_account’] = array(
      ‘key’ => ‘um_custom_validate_account’,
      ‘title’ => ( ‘Send Email for Sponsors Validation’,’ultimate-member’ ), ‘subject’ => ‘{site_name} – Someone you have sponsored on the site needs to attention’, ‘body’ => ‘Hi,

      ‘. ‘ You have sponsored “{profile_name}” on the site.

      ‘. ‘To view profile, please click the following link: {user_profile_url}’, ‘description’ =>
      (‘Whether to send the sponsor an email when someone registered has sponsored with.’,’ultimate-member’),
      ‘recipient’ => ‘admin’,
      ‘default_active’ => true
      ); return $notifications;
      }
      add_filter( ‘um_email_notifications’, ‘um_custom_validate_account’, 10, 1 );

    /**

    • I post it here, you never know it can be useful, with this code the profile and the sending of notification is done, the only problem is the link to the profile which does not work<font _mstmutation=”1″ _msthash=”1325532″>
    • Envoyer une notification par e-mail au sponsor
      */
      function um_notify_sponsors( $user_id ){ um_fetch_user( $user_id );
      $sponsor_recipient = um_user(??email_parrain??);
      $profile_name = um_user(??display_name??);
      $profile_url = um_user_profile_url( $user_id ); UM()->mail()->send( $sponsor_destinataire, ‘um_custom_validate_account’, array(‘plain_text’ => 1,’tags’ => array(‘{profile_name}’,'{profile_url}’,),’tags_replace’ => array(


      $profile_name,$profile_url,





      )
      ) );
      }
      add_action(??um_after_save_registration_details??,”um_notify_sponsors??,10, 2);

    <font _mstmutation=”1″ _msthash=”1030458″>Hello Veronica, I wish very happy holidays to the whole team and to you. Quick question, do you have a date for this future update?

    Thread Starter melchi2

    (@melchi2)

    <font _mstmutation=”1″ _msthash=”1084707″>

    Hello,
    I succeeded, the error came from my CSS modifications, thank you for your tolerance and good match

    Thread Starter melchi2

    (@melchi2)

    <font _mstmutation=”1″ _msthash=”1024283″>Everything works, the problem came from the cache, I erased everything, now no problem, sorry again

    Thread Starter melchi2

    (@melchi2)

    <font _mstmutation=”1″ _msthash=”1108341″>I deactivated all the plugins the problem persists I click to validate or reject a reservation, nothing happens but if I right click to open in a new tab it works

    Thread Starter melchi2

    (@melchi2)

    good evening Aswin, it’s sending mail that doesn’t work after I don’t know if the following syntax is good:

    key’ => ‘birth_date_45′,’birth_date_45-31’,

    I have two keys one for hosts and one for women. I don’t know if the blocking of sending mail comes from there. Thank you in advance for your assistance

    Thread Starter melchi2

    (@melchi2)

    Hello,
    Do you have a solution, thank you very much

    Thread Starter melchi2

    (@melchi2)

    Hello,

    I solved, the incident came from Loco translate which had to modify the script, after deleting the translations, it works

Viewing 15 replies - 1 through 15 (of 93 total)