Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • @magicstick That is great to hear!

    Like everyone else, this plugin is works awesome!! However I am experiencing the same problem with media attached to ACF Flexible Content fields. Media that isn’t under a ACF Flexible Content fields copies over and attaches to the duplicated post, but the others do not. Can provide you with any details you may need ??

    Thread Starter twcstuff

    (@twcstuff)

    I managed to figure it out.

    The below was used to hook into the loop for WPDiscuz that outputs the comments. Checking if there is a meta value stored under the key ‘comment_image_reloaded’, if so then append the image to the bottom of the comment.

    function legacy_comment_images($commentContent, $comment, $args) {
    
    	$attachment = get_comment_meta( $comment->comment_ID , 'comment_image_reloaded', true );
    	
    	if ( $attachment != null ){
    			$commentContent .= wp_get_attachment_image($attachment[0], 'medium');
    	}
    	
    	return $commentContent;
    }
    
    add_filter('wpdiscuz_comment_text', 'legacy_comment_images', 10, 3);
    • This reply was modified 7 years, 7 months ago by twcstuff.
    • This reply was modified 7 years, 7 months ago by twcstuff.
    Thread Starter twcstuff

    (@twcstuff)

    Or even use transition_post_status to check if the old and new status are both publish and if so, don’t trigger.

    [Moderator Note: No bumping, thank you.]

    Thread Starter twcstuff

    (@twcstuff)

    Any chance you have a fix for this? Only solution I can think of is something to do with when save_post() it tells badgeos to ignore and not trigger. Or is there a reason this is triggering?

    Thread Starter twcstuff

    (@twcstuff)

    So I used the code above, which I am glad isnt far off from my thought process. However the step of 5 posts is not being trigged if I submit a post type post (currently sitting at 4), which would push it to 5 posts. So something is not working.

    Is BadgeOS coded to JUST count posts with the type of post ?

    Is it not easier to change the step (or maybe I mean trigger technically) itself to only count posts of a certain type using a filter or action? So when I choose the step “Require Publish a Post”, can we not specifiy (not in the UI) that it only looks for post with the type post.

    It seems the way we are doing it is checking AFTER the post is published, in which case there are already 20 or so posts with the type solium_award (the one we want to exclude).

    OR

    So the filter user_deserves_achievement is applied to the function badgeos_check_achievement_completion_for_user in rules-engine.php.

    Is badgeos_check_achievement_completion_for_user triggered each time we press publish? Does it check JUST the one we published? Or does it do another loop over the triggers to see if we have made say 5 posts?

    I know there is a trigger for Publish Page and Publish Post, but when I took at look I didnt see a why to say

    if ( post_being_pushing_post_type !== 'post') {
    dont_count_as_a_trigger }

    Which would pose the problem of it only checking if THAT post was of that type, not all posts. And we cant use the action badgeos_new_{$post_type} either (if that action would help or not) as it poses the same problem.

    So my only thought is it was to be when we are checking the triggers and counting the posts.

    Thread Starter twcstuff

    (@twcstuff)

    I have a process setup to test the work.
    However I think I am unsure of exactly what $achievement_id is.
    After looking into filters I wrote this

    function dont_count_awards($achievement_id, $return) {
    
    	$post_type = get_post_type($achievement_id);
    	if ( $post_type !== 'post' ){
    	 $return = false;
    	} else {
    		$return = true;
    	}
    
    	return $return;
    
    }
    add_filter( 'user_deserves_achievement', 'dont_count_awards');

    But I dont think $achivement_id is what I thought it was. Seems like what I need to get the ID of the post we are trying to publish, run the function above to exclude any posts types except post from triggering the achievement to be “earned”

    Thread Starter twcstuff

    (@twcstuff)

    Or can we modify badgeos_user_deserves_step to check post type before counting? If that is what this function does?

    Thread Starter twcstuff

    (@twcstuff)

    Not sure if this is the way to go about it.

    function dont_count_awards() {
    
    	return apply_filters( 'user_deserves_achievement', $return, $user_id, $achievement_id, $this_trigger, $site_id, $args );
    	$post_type = get_post_type($achievement_id);
    	if ( $achievement_id !== 'post' ){
    	 $return = false;
    	}
    
    }
    
    add_action('user_deserves_achievement', 'dont_count_awards');

    Update: This def did not work, on publish it posted the article but immediately gave me a 502.

    Thread Starter twcstuff

    (@twcstuff)

    So what would be the best method for testing this function? I am not familiar with how BadgeOS really works. So thinking through a test, I would have to set some achievement, make a post of the type I want to exclude, and see if it triggers the achievement or not?

    Thread Starter twcstuff

    (@twcstuff)

    So yes, you are correct, the other types are posts as well, so it SHOULD technically be counting them. The plugin is doing its job correctly. I am curious if there is a hook or action I can add to my functions.php to tell it to exclude posts by type/tag/category etc. Because my site has award posts (saying you won an award with the company) but we dont want those to count towards posts as its 1 person that posts them and they aren’t part of the “Blog” per say.

    Does that make sense?

    Thread Starter twcstuff

    (@twcstuff)

    Hey, sorry, I wasnt very clear.

    When setting up steps for a badge, there is the Publish a new post [X] time(s). However BadgeOS counts posts published (as it even check posts from the past) it seems to be counting all types of posts. As on the site technically only have 5 REAL blog posts (real articles shows on your author profile for example) but it seems to be counting all post types. Is there a way to limit which CPT’s its looking for?

    Thread Starter twcstuff

    (@twcstuff)

    I actually got it to work.
    Because the way shortcodes work, the ] of the nested shortcode was closing off the original shortcode, screwing everything up.
    To get around this, I did the following:

    $html[] = '<div class="plan-price">'.do_shortcode('['.$price.']').'</div>';

    and

    [pt_plan price="acf field='session_price_1'" price_info="per month" type="Standard" delay="400" class="col-lg-4 col-md-4 col-sm-4"]

    and that worked great!

    Basically I just typed the text of the shortcode and ‘ instead of ” into the attribute, concatenated the [ and ] in when it prints the attribute value into the <div>, and used do_shortcode() to run the shortcode.

    Thread Starter twcstuff

    (@twcstuff)

    Not sure how to use WP FullPage if someone suggests that, I tried it. lol

Viewing 14 replies - 1 through 14 (of 14 total)