Posted on Leave a comment

Filtering WordPress Feeds

If you are using Groups by @itthinx and you need to filter the feeds, this code can help you:

function my_feed_filter ( $query ) {
  $include = array();  
  if ( $query->is_feed ) {
    $posts = Groups_Post_Access::the_posts(get_posts(array('posts_per_page'=>-1)), $query );
    foreach ($posts as $post)  {
      $include[] = $post->ID;
    }
    $query->set('post__in', $include);
  }
}
add_filter( 'pre_get_posts', 'my_feed_filter' );

Good luck !

Posted on Leave a comment

Default posts restriction

If you are using Groups plugin by @itthinx and you need to set restrictions to posts (or another post type), you can use this code as reference:

function restricted_save_post($post_id, $post) {
if(!is_object($post) || !isset($post->post_type)) {
return;
}
switch($post->post_type) { // Do different things based on the post type
case "post":
// add your default capabilities
Groups_Post_Access::create( array( 'post_id'=>$post_id, 'capability'=>'Premium' ) );
break;
default:
// Do other stuff
}
}
add_action('save_post', 'restricted_save_post', 1, 2);

This code adds the ‘Premium’ capability to all new posts when they are created.

Good luck!

Posted on Leave a comment

affiliates_is_affiliate_by_id

If you are using Affiliates by itthinx, and you need to display different content per affiliates, then you are in correct place 😉
This shortcode can help you:
add_shortcode ( 'affiliates_is_affiliate_by_id', 'affiliates_is_affiliate_by_id' );
function affiliates_is_affiliate_by_id($atts, $content = null) {
extract ( shortcode_atts ( array (
'id' => '0'
), $atts ) );
remove_shortcode ( 'affiliates_is_affiliate_by_id' );
$content = do_shortcode ( $content );
add_shortcode ( 'affiliates_is_affiliate_by_id', 'affiliates_is_affiliate_by_id' );
$output = "";
if (affiliates_user_is_affiliate ( get_current_user_id () )) {
if (affiliates_get_user_affiliate ( get_current_user_id () )[0] == $id) {
$output .= $content;
}
}
return $output;
}

Add this code in your functions.php theme file.
Example of use:
[affiliates_is_affiliate_by_id id="42"]
Only affiliate with id 42 can see this text.
[/affiliates_is_affiliate_by_id]
[affiliates_is_affiliate_by_id id="47"]
Only affiliate with id 47 can see this text.
[/affiliates_is_affiliate_by_id]

Posted on Leave a comment

extended_referrer_user shortcode

This shortcode can be used to render information about the referring affiliate’s user account.
This shortcode allows the use of the following attributes:

fields: allows to indicate which fields are to appear. For example first_name, last_name…

add_shortcode( 'extended_referrer_user', 'my_extended_referrer_user' );
function my_extended_referrer_user ( $atts, $content = null ) {
  $atts = shortcode_atts(
    array(
     'fields' => ''
    ),
    $atts
  );
  $fields = null;
  if ( !empty( $atts['fields'] ) ) {
    $fields = array_map( 'strtolower', array_map( 'trim', explode( ',', $atts['fields'] ) ) );
  }
  if ( $fields ) {
    require_once AFFILIATES_CORE_LIB . '/class-affiliates-service.php';
    $affiliate_id = Affiliates_Service::get_referrer_id();
    if ( $affiliate_id ) {
      $user_id = affiliates_get_affiliate_user( $affiliate_id );
      if ( ( $affiliate_id !== affiliates_get_direct_id() ) ) {
        if ( $user_id ) {
          foreach ( $fields as $field ) {
            echo get_user_meta($user_id, $field, true) . '
';
          }
        }
      }
    }
  }
}

Posted on 8 Comments

Woocommerce Notify Updated Product

Notify customers when their product are updated

You need:

Setup Woocommerce Notify Updated Product

If you have not done so already, install and activate the plugin. See Installation section.

In Woocommerce->Notify Updated Product section you can enable/disable the functionality also the default subject and content in the emails.

settings

From the products edit page you can configure it ( in tab ‘Notify updated Product’ )

1.- If you select ‘Send notifications’, the emails will be sent when product is updated (the system doesn’t remember this option selected to avoid sending too many emails.
2.- You can customize the subject and the email content.

product

Basic usage

Once the plugin is installed, enabled and configured, it begins to run.

When you update a product and you need to notify the customers about this update, if you select this option, then the customers will receive an email.

email

Download

Posted on Leave a comment

[affiliates_username] shortcode

If you are using Affiliates by @itthinx and you need to display the referrer username, now you can use this shortcode:
add_shortcode( 'affiliates_username', 'affiliates_username_shortcode' );
function affiliates_username_shortcode( $atts ) {
  if ( !class_exists( "Affiliates_Service" ) ) {
    include_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
  }
  $output = "";
  $affiliate_id = Affiliates_Service::get_referrer_id();
  if ( $affiliate_id ) {
    if ( $affiliate_id !== affiliates_get_direct_id() ) {
      if ( $user_id = affiliates_get_affiliate_user( $affiliate_id ) ) {
        if ( $user = get_user_by( 'id', $user_id ) ) {
          $output .= $user->user_login;
        }
      }
    }
  }
  return $output;
}