Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 376 through 400 (of 32,467 total)
  • Author
    Search Results
  • #239567
    Robin W
    Moderator

    add this to the additional css of your theme

    body.forum-archive.bbpress h5.description p {
    	display: none;
    }
    #239555

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    Just meant you need to have the that code before the afc_replace array, like below

    
    
    if( !function_exists('acf_email_bbp_subscription_mail') ){
    	function acf_email_bbp_subscription_mail( $message, $topic_id, $forum_id, $user_id ) {
    		if ( function_exists( 'get_field' ) && $topic_id != 0 ) {
    			
    			// Part for fish caught before the afc_replace
    			$fish_caught = get_field('fish_caught');
    
    			if( is_array( $fish_caught ) && isset( $fish_caught['label'] ) ){
    				$fish_caught = $fish_caught['label'];
    			}else{
    				$fish_caught = '';
    			}
    
    			// Part for image, before the afc_replace
    			$image = get_field('image');
    
    			if( is_array( $image ) && isset( $image['url'] ) && !empty( $image['url'] ) ){
    				$image = '<img src="'.esc_attr($image['url']).'" alt="'.esc_attr( $image['alt'] ).'">';
    			}else{
    				$image = '';
    			}
    
    			
    			$afc_replace = array(
    				'{catch_date_time}' => get_field( 'catch_date_time', $topic_id),
    				'{anglers}'         => get_field( 'anglers', $topic_id ),
    				'{fish_caught}'     => $fish_caught,
    				'{image}'           => $image
    				);
    
    			$message = strtr( $message , $afc_replace);
    		}
    
    		return $message;
    	}
    	add_filter( 'bbp_forum_subscription_mail_message' , 'acf_email_bbp_subscription_mail', 100 , 4 );
    }
    
    
    #239552

    In reply to: Remove white bar

    Robin W
    Moderator

    This is not related to bbpress, but to your youzify plugin

    add this to your custom css

    .youzify-bbp-topic-head {
    	display: none;
    }
    #239548

    In reply to: Subscribe to Forum

    newtech1
    Participant

    Thank you for your ongoing help we are almost there.
    But I am sorry I am not understanding this new information regarding the fish_caught field.
    I understand I would replace
    `$afc_replace = array(
    ‘{catch_date_time}’ => get_field( ‘catch_date_time’, $topic_id),
    ‘{anglers}’ => get_field( ‘anglers’, $topic_id )
    );`

    with this code
    `$afc_replace = array(
    ‘{catch_date_time}’ => get_field( ‘catch_date_time’, $topic_id),
    ‘{anglers}’ => get_field( ‘anglers’, $topic_id )
    ‘{fish_caught}’ => $fish_caught
    );`

    But not understanding where I would put this code

    $fish_caught = get_field('fish_caught');
    
    if( is_array( $fish_caught ) && isset( $fish_caught['label'] ) ){
    	$fish_caught = $fish_caught['label'];
    }else{
    	$fish_caught = '';
    }

    in the midst of this code. I am sure I am getting ( ) { } in the wrong places.

    if( !function_exists('acf_email_bbp_subscription_mail') ){
    	function acf_email_bbp_subscription_mail( $message, $topic_id, $forum_id, $user_id ) {
    		if ( function_exists( 'get_field' ) && $topic_id != 0 ) {
    #239535

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    For the fish caught sounds like you want the label name, you’d want the code to check the value before that $acf_replace array. Something like below..

    
    
    $fish_caught = get_field('fish_caught');
    
    if( is_array( $fish_caught ) && isset( $fish_caught['label'] ) ){
    	$fish_caught = $fish_caught['label'];
    }else{
    	$fish_caught = '';
    }
    
    $afc_replace = array(
    	'{catch_date_time}' => get_field( 'catch_date_time', $topic_id),
    	'{anglers}'         => get_field( 'anglers', $topic_id ),
    	'{fish_caught}'     => $fish_caught
    	);
    
    

    Same thing for the image I imagine, so you’d want the ‘url’ of the array, like above you’d want to check if it exists/uploaded before the replace array.

    
    
    $image = get_field('image');
    
    if( is_array( $image ) && isset( $image['url'] ) && !empty( $image['url'] ) ){
    	$image = '<img src="'.esc_attr($image['url']).'" alt="'.esc_attr( $image['alt'] ).'">';
    }else{
    	$image = '';
    }
    
    $afc_replace = array(
    	'{catch_date_time}' => get_field( 'catch_date_time', $topic_id),
    	'{anglers}'         => get_field( 'anglers', $topic_id ),
    	'{image}'           => $image
    	);
    
    

    Hope that helps, sorry for the delay back. I’m just a user on here so was trying to help out some while I was logged in. I’d go to ACF documention and check out their field types as they have them listed there on getting the values.

    #239527

    In reply to: Subscribe to Forum

    newtech1
    Participant

    Error-Image field
    In the email the image will not display. Most likely it is because of how I have the image field being created. I do not want posters to insert images into the website media gallery. So I have created a custom field for images. Here is the script for the image field. Is there a way to make it so images show up in the email notification? I am assuming the only work around is to allow them to access the media library.

    I know there was another way for posting images using custom field but I could never get it to work.

    <?php 
    $image = get_field('image');
    if( !empty( $image ) ): ?>
        <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
    <?php endif; ?>
    #239513

    In reply to: Subscribe to Forum

    newtech1
    Participant

    I am happy to report that code works great. The two custom fields show up in the email notification.

    Here are all the custom fields. I should be able to take what you have done and make all them work. Hopefully not break anything.

    <strong>YOU CHOOSE HOW MUCH INFORMATION YOU ENTER</strong><br>
    <strong>Catch Date & Time:</strong> <?php the_field( 'catch_date_time' ) ; ?><br>
    <strong>Anglers:</strong> <?php the_field( 'anglers' ) ; ?><br>
    <strong>Weather:</strong> <?php the_field( 'weather' ) ; ?><br>
    <strong>Fish Caught:</strong> <?php the_field( 'fish_caught' ) ; ?><br>
    <strong>Kept or Released:</strong> <?php the_field( 'kept_or_released' ) ; ?><br>
    <strong>Lake Point Marker:</strong> <?php the_field( 'lake_point_marker' ) ; ?><br>
    <strong>Water_Features:</strong> <?php the_field( 'water_features' ) ; ?><br>
    <strong>Speed:</strong> <?php the_field( 'speed' ) ; ?><br>
    <strong>Fish Depth:</strong> <?php the_field( 'fish_depth' ) ; ?><br>
    <strong>Lake Depth:</strong> <?php the_field( 'lake_depth' ) ; ?><br>
    <strong>Method Used:</strong> <?php the_field( 'method_used' ) ; ?><br>
    <strong>Lure & Color:</strong> <?php the_field( 'lure_color' ) ; ?><br>

    BUT there are two custom fields that are done differently, do not know how I would do them. It is the image field and the location field, but maybe they work the same way.

    <strong>Image:</strong>
    <?php 
    $image = get_field('image');
    if( !empty( $image ) ): ?>
        <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
    <?php endif; ?> <br>
    
    <br>
    <br>
    <strong>Fishing Location: </strong> <?php the_field( 'location' ) ; ?><br>
    <?php 
    $location = get_field('location');
    if( $location ): ?>
        <div class="acf-map" data-zoom="13">
            <div class="marker" data-lat="<?php echo esc_attr($location['lat']); ?>" data-lng="<?php echo esc_attr($location['lng']); ?>"></div>
        </div>
    <?php endif; ?>
    #239507

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    I have some updated code for you to try, after installing that ACF plugin I realized it wasn’t saving the post meta(your custom fields) before the mail was being called.

    So you’ll need to remove all the code previously listed including the first function, and try the below instead.

    So all you should have added is the below in your code snippets plugin, or functions.php file.

    
    
    if( function_exists( 'bbp_get_topic_post_type' ) ){
    	function newtech2_bbpress_new_topic( $post_id, $post , $update, $post_before ){
    	
    		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return;
    
    		if( !function_exists('bbp_get_topic_post_type') ){
    			return;
    		}
    
    		if ( bbp_get_topic_post_type() !== $post->post_type || ! is_admin() ) {
    			return;
    		}
    
    		if ( ! in_array( $post->post_status, [ 'private', 'publish' ] ) ) {
    			return;
    		}
    
    		if( isset( $post_before->post_status ) && $post_before->post_status == 'draft' ){
    			do_action( 'bbp_new_'.bbp_get_topic_post_type(), $post->ID , $post->post_parent, [] , $post->post_author );
    		}
    	}
    
    	add_action( 'wp_after_insert_post', 'newtech2_bbpress_new_topic', 10, 4);
    }
    
    if( !function_exists('acf_email_bbp_subscription_mail') ){
    	function acf_email_bbp_subscription_mail( $message, $topic_id, $forum_id, $user_id ) {
    		if ( function_exists( 'get_field' ) && $topic_id != 0 ) {
    			$afc_replace = array(
    				'{catch_date_time}' => get_field( 'catch_date_time', $topic_id),
    				'{anglers}'         => get_field( 'anglers', $topic_id )
    				);
    
    			$message = strtr( $message , $afc_replace);
    		}
    
    		return $message;
    	}
    	add_filter( 'bbp_forum_subscription_mail_message' , 'acf_email_bbp_subscription_mail', 100 , 4 );
    }
    
    

    You’ll just leave the below in your email template as before.

    
    
    Catch Time: {catch_date_time}
    Anglers: {anglers}
    
    

    Hopefully that works out for you

    #239506

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    If you’re using the style pack to edit your email template, add the below as a test to your email template.

    
    Catch Time: {catch_date_time}
    Anglers: {anglers}
    
    

    Then add this function to your functions.php file or code snippets plugin which ever your using.

    
    
    if( !function_exists('afc_email_bbp_subscription_mail') ){
    	function afc_email_bbp_subscription_mail( $message, $reply_id, $topic_id ) {
    		if ( function_exists( 'get_field' ) && $topic_id != 0 ) {
    
    			$afc_replace = array(
    				'{catch_date_time}' => get_field( 'catch_date_time', $topic_id),
    				'{anglers}'         => get_field( 'anglers', $topic_id )
    				);
    
    			$message = strtr( $message , $afc_replace);
    		}
    		return $message;
    	}
    	add_filter( 'bbp_forum_subscription_mail_message' , 'afc_email_bbp_subscription_mail', 100 , 3 );
    }
    
    

    Then test it out by creating a topic in a forum that has subscribers you can test with, and make sure to set those values when creating your topic.

    #239504

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    They are not in a template but in a functions run through filters, so if you were using bbpress without any plugins for email templates then the function it’s being called from is bbp_notify_topic_subscribers and the filter to change the message is bbp_subscription_mail_message.

    You can’t just added function with the same name, because it will cause your site to throw errors. But you can use the filter to change the message.

    Are you using bbp style pack template? If so give me the field name of one of you custom ACF fields for when you create topics, and I’ll see if I can come up with something for you.

    #239500

    In reply to: Subscribe to Forum

    newtech1
    Participant

    I put the following code within my theme’s functions.php file. I created a topic under the only forum I have on the site. I published it. Subscribers never received the notification. I checked emails log. It does not show any email being sent out. I am still wondering if the issue can be that if a topic is created within the backend instead of frontend could be causing the problem.

    /**
    *begin edit for subscribe notification to work
    */
    if( function_exists( 'bbp_get_topic_post_type' ) ){
    	function newtech1_bbpress_new_topic( $post ) {
    		if( isset( $post->post_type ) && $post->post_type == bbp_get_topic_post_type() ){
    			do_action( 'bbp_new_'.bbp_get_topic_post_type(), $post->ID , $post->post_parent, [] , $post->post_author );
    		}
    	}
    	add_action(  'draft_to_publish' ,  'newtech1_bbpress_new_topic', 10 );
    }
    /**
    *end edit for subscribe notification to work
    */
    webcreations907
    Participant

    I don’t have a multi site set up with bbpress, but try the below and see if that works for you. Would have to add to the code snippets plugin or your theme’s functions.php file

    
    
    if( !function_exists('mh_bbp_get_multi_site_total_users') ){
    	function mh_bbp_get_multi_site_total_users( $count ) {
    		if ( is_multisite() ) {
    			$args = array(
    				'blog_id'     => get_current_blog_id(),
    				'fields'      => 'ID'
    			);
    			$count = count( (array) get_users( $args ) );
    		}
    
    		return (int) $count;
    	}
    
    	add_filter( 'bbp_get_total_users' , 'mh_bbp_get_multi_site_total_users', 100 );
    }
    
    
    #239498

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    That work you for you? I was trying to post the code snippets link, but maybe it wouldn’t go through. You can find that plugin on WordPress plugins

    #239494

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    Will try posting again..

    You can try the below code, either add it to your theme’s functions.php file, or use the code snippets plugin.

    Make sure to select your “Forum” when creating a topic and make sure the forum has subscribers to test it out on.

    
    if( function_exists( 'bbp_get_topic_post_type' ) ){
    	function newtech1_bbpress_new_topic( $post ) {
    		if( isset( $post->post_type ) && $post->post_type == bbp_get_topic_post_type() ){
    			do_action( 'bbp_new_'.bbp_get_topic_post_type(), $post->ID , $post->post_parent, [] , $post->post_author );
    		}
    	}
    	add_action(  'draft_to_publish' ,  'newtech1_bbpress_new_topic', 10 );
    }
    
    #239493

    In reply to: Subscribe to Forum

    webcreations907
    Participant

    The code I just posted isn’t showing @robin-w ?

    #239484
    webcreations907
    Participant

    You could try the below

    
    .bbpress.topic-template-default .cs-entry__header{
      display: none;
    }
    
    #239476
    bastizim
    Participant

    Yes, of course. Here is my script. I thought about setting menu_order for spam posts to “0” before the loop.

    <?php
    
    require_once('wp-load.php');
    
    function repair_menu_order_gaps()
    {
        global $wpdb;
    
        $posts = $wpdb->get_results("
            SELECT ID FROM $wpdb->posts
            WHERE post_type = 'topic' AND post_status = 'publish'
            ORDER BY ID ASC
        ");
        
    
        $topic_counter = 1;
        $unterschiede = 0;
    
        foreach ($posts as $post) {
    
            $poid = $post->ID;
    
            $replies  = $wpdb->get_results("
            SELECT menu_order, ID FROM $wpdb->posts
            WHERE post_type = 'reply' AND post_status = 'publish' AND post_parent=$post->ID ORDER BY menu_order ASC");
            
            $order=0;
            $counter = 0;
    
            $ids = array();
            $menu_orders = array();
            foreach ($replies as $reply) {
                $counter++;
                $order=$reply->menu_order;
                $ids[] = $reply->ID;
                $menu_orders[] = $reply->menu_order;   
            }
    
            if($counter!=$order) {
                echo "Abweichung gefunden in Post $poid: Counter $counter , Order = $order </br/>";
                $unterschiede++;
    
                $counter_rep = 0;
                foreach ($ids as $id) {
    	        $order=$menu_orders[$counter_rep];
                    $counter_rep++;
                    
    
                    echo "Neue Nummer für $id: $counter_rep (Alt: $order)<br/>";
                    
                    // Set new menu_order
                    $wpdb->update(
                        $wpdb->posts,
                        array('menu_order' => $counter_rep),
                        array('ID' => $id)
                    );
                
    
                }
            } 
    
            $topic_counter++;
        }
    
    #239448
    Story Saver
    Participant

    Custom code is required for displaying it in your forums. You should insert the provided code into either your functions.php file, bbpress-functions.php file, or a functionality plugin.
    https://storysaver.page/

    #239441
    biblewithbelle
    Participant

    Hi,

    My theme is creating a featured image on the Topics which I can’t seem to change so I just have a large grey blob square at the top of every topic.

    Introduce Yourself

    I tried multiple default image wordpress themes and none of them worked.

    I can’t add code to display: none because then it takes away the featured posts from the blog section.

    Help?

    #239375
    lifeguard81
    Participant

    Hi guys,

    after install i see some strange code under profilenames. Only as admin i see this.
    What is this?

    https://i.imgur.com/4TODpKr.png

    #239362
    getfree
    Participant

    That worked. GPT insisted that the function call was not needed even when specifically asked. Also it thought that the square brackets are some short codes that were a must, which confused me even more. The text (a poker hand history from a software) starts like this:
    [converted_hand][hand_history]PokerStars – €0.50 PL Hi FAST (6 max) – Omaha Hi – 6 players
    [url=”http://www.holdemmanager.com”%5DHand converted by Holdem Manager 3[/url]

    BTN: €52.28 (104.6 bb)
    [color=”grey”]SB: €24.25 (49 bb)
    [/color][b]Hero (BB): €84.89 (169.8 bb)
    [/b][color=”grey”]UTG: €52.86 (105.7 bb)
    [/color][color=”grey”]MP: €31.34 (62.7 bb)
    [/color][color=”grey”]CO: €50.00 (100 bb)
    [/color]
    SB posts €0.25, Hero posts BB €0.50

    If I get this thing working I will make sure to update my old question about the hand histories in case some1 else is looking for a similar thing.
    Thanks Robin!

    #239361
    Robin W
    Moderator

    ok, the code is probably ok, but chat gpt has a long way to go !

    A function needs something to call it, otherwise it just sits there.

    Not tested, but add these 2 lines before or after (doesn’t matter which) the function

    add_filter( 'bbp_get_reply_content', 'replace_suit_symbols' ) ;
    add_filter( 'bbp_get_topic_content', 'replace_suit_symbols' ) ;
    #239360
    getfree
    Participant

    yes, on bbpress forums.

    I got the code from Chat GPT which ensured me that it would work (ie. clicking send would call the function and execute it) and gave me a few other pieces of more or less similar type of code. As you can see I am quite clueless on this stuff albeit I used to know some Python.

    How to proceed..

    This is related to this https://bbpress.org/forums/topic/poker-hand-histories-not-converted/#post-237481
    We have some freelance developers helping out but they didn’t understand at all what I was trying to accomplish, so I am set to do this “alone” for now, with not much success :/

    #239359
    Robin W
    Moderator

    ok so unless you have some further code, nothing is calling that function.

    I presume this is content on bbpress topics and replies – yes?

    #239358
    getfree
    Participant

    hi,
    I am trying to parse pasted text into something else, where the simplest thing is to change :spade: :club: :diamond: and :heart: to be visualized as ♠♣♦ and ♥ but my solution is not working.

    In the Theme files I edited functions.php by adding the following code (in the staging environment)

    // Function to replace suit representations with symbols
    function replace_suit_symbols($hand_history) {
        // Replace suit representations with symbols
        $hand_history = str_replace(':spade:', '♠', $hand_history);
        $hand_history = str_replace(':heart:', '♥', $hand_history);
        $hand_history = str_replace(':diamond:', '♦', $hand_history);
        $hand_history = str_replace(':club:', '♣', $hand_history);
        
        // Return the modified hand history
        return $hand_history;
    }

    But when I write “:spade”, for instance, nothing changes. What am I missing?
    Hello Theme, WP 6.4.3, bbPress 2.6.9.

Viewing 25 results - 376 through 400 (of 32,467 total)
Skip to toolbar