Archives: Snippets
WordPress – Display the Last Updated Date
$u_time = get_the_time( ‘U’ ); $u_modified_time = get_the_modified_time( ‘U’ ); // Only display modified date if 24hrs have passed since the post was published. if ( $u_modified_time >= $u_time + 86400 ) { $updated_date = get_the_modified_time( ‘F jS, Y’ );…Continue reading
MihaiJoe
Dynamic Copyright Date
if ( ! function_exists( ‘wpb_copyright’ ) ) { function wpb_copyright() { // Cache the output so we don’t have to run the query on every page load. $output = get_transient( ‘wpb_copyright_text’ ); if ( false !== $output ) { //…Continue reading
HealthEngine
MemberPress: Unsubscribed Memberships Shortcode
add_shortcode( ‘mepr-unsubscribed-memberships’, function () { $args = array( ‘post_type’ => ‘memberpressproduct’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ); $memberships = new WP_Query( $args ); ob_start(); if ( $memberships->have_posts() ) { echo ‘ ‘; while ( $memberships->have_posts() ) { $memberships->the_post(); $post_ID…Continue reading
MemberPress: Restrict Signups for US-Based Users
function limit_signups_to_excluded_regions( $errors ) { // Check if the country field is set If ( isset( $_POST[ ‘mepr-address-country’ ] ) ) { $country = sanitize_text_field( wp_unslash( $_POST[ ‘mepr-address-country’ ] ) ); // Exclude EU countries if ( $country == ‘US’…Continue reading
MemberPress: Restrict Signups for EU-Based Users
function limit_signups_to_excluded_regions( $errors ) { // List of EU country codes $eu_countries = array( ‘AT’, ‘BE’, ‘BG’, ‘HR’, ‘CY’, ‘CZ’, ‘DK’, ‘EE’, ‘FI’, ‘FR’, ‘DE’, ‘EL’, ‘HU’, ‘IE’, ‘IT’, ‘LV’, ‘LT’, ‘LU’, ‘MT’, ‘NL’, ‘PL’, ‘PT’, ‘RO’, ‘SK’, ‘SI’, ‘ES’,…Continue reading
MemberPress: Restrict Signups for Northern Ireland-Based Users
function limit_signups_to_excluded_regions($errors) { // Check if the country field is set if ( isset( $_POST[ ‘mepr-address-country’ ] ) ) { $country = sanitize_text_field( wp_unslash( $_POST[ ‘mepr-address-country’ ] ) ); // Exclude Northern Ireland under UK country code if( $country ==…Continue reading
MemberPress: Adding Credit Card and Expiry Information to Subscriptions Table
// Add the “Card/Expiry” column header function mepr_add_subscriptions_th($user, $subs) { ?> Card/ExpiryContinue reading