Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,626 through 1,650 (of 32,438 total)
  • Author
    Search Results
  • #220553
    Robin W
    Moderator

    unanswered can be done by

    bbp style pack

    once activated

    create a wordpress page and use the [bsp-display-topic-index …..] shortcode

    see

    dashboard>settings>bbp style pack>Shortcodes for how to use it – but create one with noreply

    then you just create a link to that page

    #220516
    Robin W
    Moderator

    so maybe have a function that says

    add_action( 'bbp_theme_after_reply_form_content', 'rew_add_checkbox' );
    
    function rew_add_checkbox () {
    echo '<p class="whatever">
    <input name="my_parameter" id="my_parameter" type="checkbox" value="whatever_value_you_want" checked="checked">								<label for="whatever">Tick this box to do whatever</label>
    </p>' ;
    
    }

    This will put the checkbox after the content

    #220515
    Robin W
    Moderator

    without knowing what you are trying to achieve hard to say.

    Typically you’d use JS for stuff you want to change on the fly without reloading the screen.

    For an input form you would more normally use html and php

    But I do fully appreciate that we all play to our strengths and I would tend to use PHP where JS would be better as I know it well, and I suspect you are the reverse 🙂

    So you would add a checkbox, you can do this by amending the reply template, or better using one of the do_action hooks in the template. You can also do this using JS

    In essence you are adding this to the form, you can use whatever names you want

    <p class="whatever">
    <input name="my_parameter" id="my_parameter" type="checkbox" value="whatever_value_you_want" checked="checked">								<label for="whatever">Tick this box to do whatever</label>
    </p>

    This will create a box which when submitted will set
    $_POST[‘my_parameter’] to “whatever_value_you_want” if ticked or be blank if not

    you can use the code above to set your meta data

    #220514
    vincenzon617
    Participant

    I am having some difficulty figuring out what this does, apologies, my PHP knowledge is very minimal. What exactly is the

    if (! empty($_POST[‘my_parameter’] ) ) {
    $myvalue = $_POST[‘my_parameter’] ;
    }
    else $myvalue='empty';

    part doing? Specifically, what would ‘my_parameter’ be? Would this be the name or value of what I would like the meta to be?
    I have looked up what $_POST does, and the variables that I am using are declared using JavaScript. Now I am wondering if I will have to change my approach to checking the user input for the checkbox (something which isn’t related to bbpress).

    Many thanks

    #220505

    In reply to: bbpress redirection

    Robin W
    Moderator

    how are they loggong on wp-logon, or widget or shortcode?

    #220491
    Robin W
    Moderator

    you’ll want to use update_post_meta – this creates the entry if not there and amends it if it is.
    in the new reply handler, there is a hook which contains the reply_id which fires after the reply is created.

    so something like

    add_action( 'bbp_new_reply_post_extras', 'rew_reply_checkbox' );
    add_action( 'bbp_edit_reply_post_extras', 'rew_reply_checkbox' );
    
    function rew_reply_checkbox ($reply_id) {
    //and probably set the value to a $_POST parameter you set in the form
    if (! empty($_POST[‘my_parameter’] ) ) {
    $myvalue = $_POST[‘my_parameter’] ;
    }
    else $myvalue='empty' ;
    
    update_post_meta ($reply_id , 'my_parameter', $myvalue) ;
    }
    #220490
    #220470
    vincenzon617
    Participant

    I have managed to find the solution! For anyone else who may have this problem, change this part of the code above:

    .innerHTML = "clicked";
    to
    .value += "clicked";

    vincenzon617
    Participant

    Is there a way to append text to the reply form using JavaScript?
    I have this function

    window.onload=function() {
    	document.getElementById("toggle-check").addEventListener("click", funct1);
    	
    	function funct1() {
      		
    		if(this.checked) {
    			
    			document.getElementById('bbp_reply_content').innerHTML = "clicked";
    		} else {
    			
    			document.getElementById('bbp_reply_content').innerHTML = "notclicked";
    		};
      		
    	};
    };

    which is used when the user clicks a checkbox that I have made. I would like the text to be appended to the reply form at the end of their message, depending on whether or not they have clicked the checkbox. Currently, the .innerHTML is not working when there is text already in the reply form but it works when the reply form is empty.

    Has anyone got any ideas on how to do this? Maybe there is a text variable that stores the user’s message that I can append to – if so what is the name?

    Many thanks

    #220451
    webmasterfreya
    Participant

    Hi Back to Front,

    I also have buddypress installed. As admin you have for each member a page wich among other things shows topics started and replies made by the member. The replies did not show up (and there were definitly replies).

    As buddypress makes use of bbpress for fora i expected your code to work but it did not (is the culprit then buddypress or bbpress or your code? I haven’t the faintest idea).

    Maybe : if( $bbPress_post_type ==’topic’ ){

    /** TOPIC **/
    $query[‘order’]=’DESC’;
    return $query;

    should have an } else {return $query}

    sino27
    Participant

    Hi there. Sorry for reviving this thread. But I had to as this is some serious privacy issue.

    A code from “bjornwebdesign” is definitely working but not completely. I mean on this code posted in his “Ok, last time, I promise :p…”

    /*
     * Do stuff when the user's xprofile is updated
    */	
    function xprofile_updated ( $user_id, $posted_field_ids, $errors, $old_values, $new_values) {
    	/*
    	 * Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
    	 * Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
    	 * Altough this should run AFTER updating profile fields (saving to DB), the nicename is only updated after a second save. So we need to check from $new_values
    	 */
    	$new_display_name = '';
    	foreach ( $new_values as $key => $value ) {
    		if ( is_array($value) && $key == 1 ) { // field display_name = 1, make sure this is correct
    			foreach ( $value as $k => $v ) {
    				if ( $k == 'value' ) {
    					$new_display_name = $v;
    				}
    			}
    		}
    	}
    	//error_log('******** xprofile_updated: '.$user_id.' | NEW DISPLAY_NAME: '.$new_display_name.' *********');
    	$search = array( ' ', '.' ); 
    	$replace = array( '_', '' );
    	$user = get_user_by( 'ID', $user_id );		
    	if ( $user ) {
    		if ( $user->data->user_status == 0 && $new_display_name ) {
    			$new_user_nicename = strtolower(str_replace( $search, $replace, $new_display_name) );
    			if ( strlen ( $new_user_nicename ) > 50 ) {
    				$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
    			}				
    			if ( $user->data->user_nicename != $new_user_nicename ) { // && $user->ID == 80 <-Add this if you only want to run it for 1 user, so you can test it.
    				$args = array(
    					'ID'            => $user->ID,
    					'user_nicename' => $new_user_nicename
    				);
    				wp_update_user( $args );
    				//error_log('******** updated user_nicename: '.$user->ID.' | NEW USER_NICENAME: '.$new_user_nicename.' *********');
    				wp_redirect( get_site_url().'/leden/'.$new_user_nicename.'/profile/edit/group/1/' ); // we cant use bp_core_get_user_domain() here, because it still uses the old user_nicename
    				exit;					
    			}
    		}
    	}
    }
    add_action( 'xprofile_updated_profile',  'xprofile_updated', 100, 5 );

    – but there is one critical flaw. After code is applied, user can not update their profile anymore. Like you can go to (example) update name or nickname. You press save and nothing changes. Profile is not updated.

    If I apply “bjornwebdesign” previous code (meaning code he posted just before his latest code) –

    
    /*
     * Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
     * This runs allways (with init hook), we should only do this once and then on user register & profile update..
     * Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
     * And offcourse allways use something like: 'bp_core_get_user_domain( $user_id )' when you want to get the user's profile url.
     */
    $search = array( ' ', '.' ); 
    $replace = array( '_', '' );
    $all_users = get_users();		
    foreach ( $all_users as $user ) {
    	$display_name = $user->data->display_name;
    	if ( $user->data->user_status == 0 && $display_name ) {
    		$new_user_nicename = strtolower(str_replace( $search, $replace, $display_name) );
    		if ( strlen ( $new_user_nicename ) > 50 ) {
    			$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
    		}				
    		if ( $user->data->user_nicename != $new_user_nicename ) { // && $user->ID == 80 <-Add this if you only want to run it for 1 user, so you can test it.
    			$args = array(
    				'ID'            => $user->ID,
    				'user_nicename' => $new_user_nicename
    			);
    			wp_update_user( $args );					
    		}
    	}
    }
    

    then updating of profile is working. User can update profile but after pressing “Save” there is 404 error. Even 404 is acceptable as at least user can update their profile. However performance is severely degraded on a website with many members.

    So basically only his latest code is working in a way that their profile URL is hidden, performance is not degraded but user profiles can not be saved or updated. Can anyone help and update his code so that user are able to update their profiles?

    #220433
    deborah86
    Participant

    Will the shortcodes be converted into blocks to work fully with the block editor? Is bbPress preparing for full-site editing that is coming this year?

    deborah86
    Participant

    I am currently using the Twenty Twenty theme. The theme is causing jumbled text on the forum page.

    Forum Page

    I have tried both bbPress and BuddyBoss. I have the same issue. I contacted BuddyBoss, they stated there is an issue with the Twenty Twenty theme. I contacted the admins at the Twenty Twenty theme. They told me to go to bbPress for support. I cannot locate the issue in the code.

    See Twenty Twenty theme ticket

    I also completed the additional troubleshooting steps:

    • Deactive plugins – this did not solve the issue
    • Themes – switching the themes fixes the issue. I contacted the Twenty Twenty theme authors. They told me to contact you.
    • Selecting the default permalinks – I am already using the default permalinks
    • Repair Forums – this did not solve the issue
    • Using WP Debug – no debug issues appeared
    • Diagnose Javascript errors – there are no javascript errors appearing

    I have basically tried everything besides resetting my WordPress website. Nothing seems to work.

    #220395
    Robin W
    Moderator

    ah yes, it should have been

    bbp_get_reply_type()

    to make it a function, but ‘reply’ is equally as good

    #220394
    vincenzon617
    Participant

    Thanks, Robin works great, although the bbp_get_reply_type and bbp_get_topic_type caused an error so I replaced it with bbp_get_all_child_ids($topicID, 'reply'); and it seems to have done the trick!

    #220387
    Robin W
    Moderator

    or

    $ids = bbp_get_all_child_ids($topicID , bbp_get_reply_type) ;

    #220386
    Robin W
    Moderator

    a quick look at that function would seem to be

    $ids = bbp_get_all_child_ids($topicID , bbp_get_topic_type) ;

    Robin W
    Moderator

    untested, but try

    add_filter( 'bbp_get_view_query_args', 'rew_limit') ;
    
    function rew_limit ($args) {
    $args['posts_per_page'] = -1 ;
    $args['posts_per_page'= 10 ;
    return $args ;
    }

    not sure which 10 it will show!!

    vincenzon617
    Participant

    Is there a way to limit the number of topics shown when using the shortcode [bbp-single-view id=’popular’]?

    I would only like to show the top 10 most popular topics.

    Thanks

    #220360
    webmasterfreya
    Participant

    Hi,

    Your piece of code has an unwanted side effect. When looking at a subscriber as admin the created replies of this subscriber do not show anymore.
    I reverted back to the original code (on top of this topic) and presto the replies of the subscriber show up again.

    #220346
    maxx203
    Participant

    Hello

    to clean up my pending and spam threads and answers, iam using two show SQL queries. Is there maybe any plugin or cron which can execute them?

    DELETE FROM wp_posts WHERE post_status = "pending";
    DELETE FROM wp_posts WHERE post_status = "spam";

    Regards
    Maxx

    #220343
    Robin W
    Moderator

    @traverser11 – great that you are posting the answers here – so many don’t 🙂 🙂 🙂

    can you summarise where you are at, so eg

    use this plugin (are you still using the sort topic replies plugin?)
    delete this code from it
    add this code to this place

    etc.

    so it is all in one thread, I’ll then try to give to some switch on and off code

    #220341
    Back to Front
    Participant

    Oh here is an answer!

    Wrong bbp_get_reply_url() when paging with reverse order

    This snippet works – i’m just a bit confused how to turn it on when replies are descending and off when they are ascending…

    add_filter('bbp_get_reply_position', 'lugpa_get_reply_position', 10, 3);
    function lugpa_get_reply_position($reply_position, $reply_id, $topic_id){
        
        if(empty($topic_id))
            $topic_id = bbp_get_reply_topic_id ($reply_id);
        
        $numReplies = bbp_get_topic_reply_count($topic_id);
        return ($numReplies+1) - $reply_position; // plus one because of thread description
    }
    #220323
    Robin W
    Moderator
    #220320
    Back to Front
    Participant

    I gave it a go, and it kinda worked, lol…
    But this reverses all the replies INCLUDING the original topic.
    So the original topic goes to the bottom…
    What I would ideally want is the Topic, THEN the replies in reverse order…

    // Reverse reply order on News topic
    
    add_filter('bbp_has_replies_query','bbp_reverse_reply_order');
    function bbp_reverse_reply_order( $query = array() ) {
    	// Identify post type
    	$bbPress_post_id = get_the_ID();
    	$bbPress_post_type = get_post_type($bbPress_post_id);
    
    	if( $bbPress_post_type =='topic' ){
    
    		/** TOPIC **/
    			$query['order']='DESC';
    			return $query;
    
      }
    };
Viewing 25 results - 1,626 through 1,650 (of 32,438 total)
Skip to toolbar