Support » Plugin: Front End PM » Only show message area/box if user has post

  • Resolved lspoe2

    (@lspoe2)


    Hi,

    I found the below code in the forums and I’m trying to get it work with my site.

    I have two users roles and each role has a different CPT.

    I would like to check if user has CPT post.

    Example, check if user with role “Author” has post in CPT “job” and if they do then the message box can show.

    Is this possible? Thanks in advance for your help.

    add_filter( ‘fep_current_user_can’, function( $can, $cap, $id ){
    if( ‘access_message’ !== $cap || ! $can ) {
    return $can;
    }
    if ( ! count_user_posts( get_current_user_id(), ‘jobs’ ) ) {
    $can = false;
    }

    return $can;
    }, 10, 3);

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.