akemx (March 30th, 2013)
/*---------------- Member Only Content ------------------*/
function member_only( $atts, $content = null ) {
if ( is_user_logged_in() ) {
return '<div class="member-only">' .$content. '</div>' ;
}
}
add_shortcode('member_only', 'member_only');
/*---------------- Contributor Only Content ------------------*/
function contributor_only( $atts, $content = null ) {
$user_ID = get_current_user_id();
$articles = count_user_posts( $user_ID );
if ( is_user_logged_in() && $articles > 0 ) {
return '<div class="contributor-only">' .$content. '</div>' ;
}
}
add_shortcode('contributor_only', 'contributor_only');
/*---------------- Listing Owner Only Content ------------------*/
function tmm_count_user_listing( $user_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, VA_LISTING_PTYPE ) );
}
function listing_owner_only( $atts, $content = null ) {
$user_ID = get_current_user_id();
$listings = tmm_count_user_listing($user_ID);
if ( is_user_logged_in() && $listings > 0 ) {
return '<div class="lister-only">' .$content. '</div>' ;
}
}
add_shortcode('listing_owner_only', 'listing_owner_only');
akemx (March 30th, 2013)
akemx (April 2nd, 2013)
There are currently 1 users browsing this thread. (0 members and 1 guests)