Time delay between 2 messages


Home Forums Front End PM PRO Time delay between 2 messages

This topic is: Resolved

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7946
    Ciro Scognamiglio
    Participant

    Is possible to set 2 different time delay between 2 messages?

    EDIT:

    i use s2members roles (s2member level 1,s2member level 2,s2member level 3,s2member level 4)
    for level 1 and 2 i need max one message a week, level 3 and 4 can send 2 message a week
    like this or similar

    #7949
    shamim
    Keymaster

    Please go to Dashboard > Front End PM PRO > Settings > General and set “Time delay” as 0

    Then add following code in your theme’s (child theme’s if any) functions.php

    
    add_action( 'fep_action_validate_form', 'fep_cus_diff_time_delay_for_roles', 10, 2);
    
    function fep_cus_diff_time_delay_for_roles( $where, $errors ) {
    
        if( 'newmessage' != $where )
            return;
            
        $args = array(
            'post_type' => 'fep_message',
            'post_status' => array( 'pending', 'publish' ),
            'posts_per_page' => 2,
            'author'	   => get_current_user_id(),
            'date_query' => array(
                'after' => '-1 week'
                ) 
            );
        if( 'threaded' == fep_get_message_view() )
            $args['post_parent'] = 0;
        
        $posts = get_posts( $args );
        
        if( ! $posts )
        return;
        
        $roles = wp_get_current_user()->roles;
        
        if( array_intersect( array( 's2member_level1', 's2member_level2'), $roles ) ) {
            $errors->add('time_delay', __( 'You can send maximum 1 message a week.', 'front-end-pm' ) );
        } elseif( count( $posts ) >= 2 && array_intersect( array( 's2member_level3', 's2member_level4'), $roles ) ){
            $errors->add('time_delay', __( 'You can send maximum 2 messages a week.', 'front-end-pm' ) );
        }
    }
    
    #7952
    Ciro Scognamiglio
    Participant

    nice!it’s works fine, thank you!!!!!

Viewing 3 posts - 1 through 3 (of 3 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.