Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 8,951 through 8,975 (of 32,505 total)
  • Author
    Search Results
  • #161125
    Robkk
    Moderator

    @dmclean

    well its tough on my side too since you have a paid theme (the free version doesnt have the show excerpt option) , so i cant just tell you step by step because i have to look at the code of your current theme.

    you can create me an admin account ( i need to go to the backend and see your theme files in the wordpress theme editor ) , then send me the login details through my email so i can get this done for you.

    Contact

    #161121

    In reply to: Add Custom User Roles

    Alice Kaye
    Participant

    Okay, so kind of resurrecting my old thread here, but with good reason, because something has gone wrong with the code. Today, I promoted someone (the first person to be promoted to this rank) Artisan, which I’ve hand coded into my functions.php file.

    The code:

    /* bbPress Custom Roles */
    function add_custom_role( $bbp_roles ) {
    
    $bbp_roles['bbp_craftsman'] = array(
    'name' => 'Craftsman',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    );
    $bbp_roles['bbp_journeyman'] = array(
    'name' => 'Journeyman',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    );
    $bbp_roles['bbp_adept'] = array(
    'name' => 'Adept',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    );
    $bbp_roles['bbp_artisan'] = array(
    'name' => 'Artisan',
    'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() ) // the same capabilities as moderator
    );
    $moderator = bbp_get_moderator_role() ;
    $bbp_roles[$moderator] = array(
    'name' => 'Councilman',
    'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() ) // the same capabilities as moderator
    );
    $keymaster = bbp_get_keymaster_role() ;
    $bbp_roles[$keymaster] = array(
    'name' => 'Advisor',
    'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() ) // the same capabilities as keymaster
    );
    $apprentice = bbp_get_participant_role() ;
    $bbp_roles[$apprentice] = array(
    'name' => 'Apprentice',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    );
    return $bbp_roles;
    }
    add_filter( 'bbp_get_dynamic_roles', 'add_custom_role', 1 );
    /* bbPress Custom Roles */

    As you can see, the way I’ve written it, I had Artisan and Councilman both as moderator roles. This is really how I need it set up.

    Currently I’ve adjusted Artisan to:

    $bbp_roles['bbp_artisan'] = array(
    'name' => 'Artisan',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    );

    Because for whatever reason, when set to moderator, she could not see our forums at all.

    Is there a way to have two moderator ranks, or can there only be one? If so, where have I gone wrong with this? I’m quite confused over it now.

    Thanks in advance, you guys have been so helpful through all of my learning. 🙂

    #161120
    project_subdomain
    Participant

    just noticed the unlogical doubled url in the code above, but my other tries like for example

    $id = bb_get_user_id();
    $user = bb_get_username();
    $nicename = bb_get_user_nicename('$id','$user');
    
    header('Location: http://domain.com/forums/users/'.$nicename);

    also should have a mistake.

    #161119
    project_subdomain
    Participant

    [WP 4.1.1
    bbp 2.5.6]

    For creating a navigation menu I need to redirect pages to the bbpress profile url as well as to their default options urls. These are domain.com/forums/users/HERE-COMES-THE-USERNAME for showing profile and domain.com/forums/users/HERE-COMES-THE-USERNAME/HERE-COMES-SELECTED-OPTION for selected options.

    I tried several ways with code like this on the page’s template file for the redirection to the profile but nothing worked yet.

    <?php /*  
    Template Name: show user profile
    */ 
    
    $name= bbp_user_profile_url(bbp_get_current_user_id() );
    
    header('Location: http://domain.com/forums/users/'.$name);
    exit();
    
    ?>

    Thanks for helping!

    #161111
    Dmclean
    Participant

    I’m uncomfortable changing the theme code with the explanations on the link that was given. Can you be more specific as to what I need to do? Thanks!

    #161107
    Robin W
    Moderator

    1.
    The following if added to your functions file will add fields, you can alter the coding as needed

    //add code for adding first and last name to registration
    
    //1. Add a new form element...
        add_action('register_form','myplugin_register_form');
        function myplugin_register_form (){
            $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: '';
    		$last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: '';
            ?>
    		<p>
    		<label for="first_name"><?php _e('First Name  as people call you eg Dave','mydomain') ?><br />
                    <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(stripslashes($first_name)); ?>" size="25" /></label>
            </p>
    		<p>
                <label for="last_name"><?php _e('Last Name','mydomain') ?><br />
                    <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr(stripslashes($last_name)); ?>" size="25" /></label>
            </p>
            <?php
        }
    
        //2. Add validation. In this case, we make sure first_name is required.
        add_filter('registration_errors', 'myplugin_registration_errors', 10, 3);
        function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {
    
            if ( empty( $_POST['first_name'] ) )
                $errors->add( 'first_name_error', __('<strong>ERROR</strong>: You must include a first name.','mydomain') );
    		if ( empty( $_POST['last_name'] ) )
                $errors->add( 'last_name_error', __('<strong>ERROR</strong>: You must include a last name.','mydomain') );
    			
    
            return $errors;
        }
    
        //3. Finally, save our extra registration user meta.
        add_action('user_register', 'myplugin_user_register');
        function myplugin_user_register ($user_id) {
            if ( isset( $_POST['first_name'] ) )
                update_user_meta($user_id, 'first_name', $_POST['first_name']);
    		if ( isset( $_POST['last_name'] ) )
                update_user_meta($user_id, 'last_name', $_POST['last_name']);
        }
    

    Plenty of captcha plugins – just google ‘wordpress plugin captcha’

    If you’d like to specify your req’s further, I’ll try to help.

    2. no need to change theme, just add the following to your css file

    .site-content .entry-header, .site-content .entry-content, .site-content .entry-summary, .site-content .entry-meta, .page-content {
      max-width: 100% !important;
    }

    Functions files and child themes – explained !

    #161089
    Robin W
    Moderator

    that is entirely intentional – it lets keymasters see IP addresses to spot people who might post under several names.

    you could hide it with css

    .bbp-reply-ip {
    display : none !important ;
    }

    or amend line 512 of loop-single-reply

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-reply.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-reply.php
    bbPress will now use this template instead of the original

    then take out line 51 – you may also need to do this to loop-single-topic

    or use a filter to get rid of it

    function remove_ip () {
    $author_ip = '' ;
    return $author_ip ;
    }
    
    add_filter( 'bbp_get_author_ip', 'remove_ip');
    
    #161085
    Robin W
    Moderator

    sorry capabilities are forum wide, and lots of code would be needed to make them forum specific.

    I can’t immediately think of an alternate solution

    #161081
    redwolf83
    Participant

    Thanks, that is very helpful, but it change roles globally. I need it for a specific forum.

    • is possible call these actions to an existing role?
    • and is possible call them only for a specific forum

    I tried this but seems not work…. :/

    // BBPRESS ROLES CONFIG FOR SPECIFIC FORUM
    
    if ( bbp_forum_title(); == "My Forum Title" ) {
    
    	function add_role_caps_filter( $caps, $role )
    	{
        	/* Only filter for roles we are interested in! */
        	if( $role == 'participant' )
            	$caps = custom_capabilities( $role );
     
    	    return $caps;
    	}
     
    	add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
     
    	function custom_capabilities( $role )
    	{
        	switch ( $role )
        	{
     
            	/* Capabilities for 'tutor' role */
            	case 'participant':
               	 return array(
                    	// Primary caps
                   		'spectate'              => true,
                    	'participate'           => true,
                    	'moderate'              => false,
                    	'throttle'              => false,
                    	'view_trash'            => false,
     
                    	// Forum caps
                    	'publish_forums'        => false,
                    	'edit_forums'           => false,
                    	'edit_others_forums'    => false,
                    	'delete_forums'         => false,
                    	'delete_others_forums'  => false,
                    	'read_private_forums'   => false,
                    	'read_hidden_forums'    => false,
     
                    	// Topic caps
                    	'publish_topics'        => false,
                    	'edit_topics'           => false,
                    	'edit_others_topics'    => false,
                    	'delete_topics'         => false,
                    	'delete_others_topics'  => false,
                    	'read_private_topics'   => false,
     
    	                // Reply caps
    	                'publish_replies'       => true,
                    	'edit_replies'          => true,
                    	'edit_others_replies'   => false,
                    	'delete_replies'        => true,
                    	'delete_others_replies' => false,
                    	'read_private_replies'  => false,
     
                    	// Topic tag caps
                    	'manage_topic_tags'     => false,
                    	'edit_topic_tags'       => false,
                    	'delete_topic_tags'     => false,
                    	'assign_topic_tags'     => false,
               	 );
     
                	break;
     
            	default :
               	return $role;
        		}
    	}
    }
    #161079
    Robin W
    Moderator
    #161068
    sina_mech
    Participant

    Thank you for your reply. I have “bbpress” folder in MY_THEME folder. I added a functions.php file in that bbpress folder, and inserted your code, and saved. but nothing happened 🙁 Am I doing it right?

    #161065
    Robkk
    Moderator

    @snecz

    i gave you two shortcodes for each instead

    place the two functions into your child themes functions.php or add the snippets to a functionality plugin.

    [bbp-topic-stats]

    function rk_bbp_topic_stats() {
        $stats = bbp_get_statistics();
        echo "<dl role='main'><dt>Topics</dt><dd><strong>";
        echo esc_html( $stats['topic_count'] );
        echo "</strong></dd></dl>";
    }
    
    add_shortcode('bbp-topic-stats', 'rk_bbp_topic_stats'); 

    [bbp-reply-stats]

    function rk_bbp_reply_stats() {
        $stats = bbp_get_statistics();
        echo "<dl role='main'><dt>Replies</dt><dd><strong>";
        echo esc_html( $stats['reply_count'] );
        echo "</strong></dd></dl>";
    }
    
    add_shortcode('bbp-reply-stats', 'rk_bbp_reply_stats');  
    #161064
    Robkk
    Moderator

    @sina_mech

    add this into your child themes functions.php file or put the snippet in a functionality plugin.

    function rk_new_topic_button() {
    	echo '<a href="#new-topic-0" class="bbp-new-topic-button button btn input[type="button"]" >New Topic</a>';
    }
    
    add_action('bbp_template_before_topics_loop','rk_new_topic_button');
    #161062
    Robkk
    Moderator

    add this to your child themes functions.php file or insert this snippet into a functionality plugin and all links posted to your forum would just return plain text.

    remove_filter( 'bbp_get_reply_content', 'bbp_make_clickable', 4    );	
    remove_filter( 'bbp_get_topic_content', 'bbp_make_clickable', 4    );
    #161058
    Stephen Edgar
    Keymaster

    Either comment out the code section using standard PHP syntax or simply remove that chunk of code 🙂

    #161055
    Robin W
    Moderator

    If your site is that busy, you really should have a test site

    https://codex.bbpress.org/creating-a-test-site/

    Dan & Jennifer
    Participant

    Hi there!

    We’re trying to move our forums from a custom Q&A platform to bbPress… very glad there is now an importer! 🙂

    So I copied example.php to myimport.php, changed the class name, and updated the tables/columns that apply (the ones that exist in the old database).

    And ran the import…

    But I keep running into import errors for fields that don’t apply as they don’t exist in the other database, like forums_table.the_reply_count

    So for a field that just does not exist in the old database, what’s the proper syntax for “ignore this”? 🙂

    For example, this one…

    
    // Forum topic count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'forums_table',
    			'from_fieldname' => 'the_topic_count',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_topic_count'
    		);
    

    I looked for this on the importer codex page, but just don’t see it. 🙂

    Thanks!
    Dan

    #161045
    snecz
    Participant

    Thanks Robkk. [bbp-stats] is working. But I need topic count and replies count separately and in different places.
    So I’ve tried with <?php echo esc_html( $stats['topic_count'] ); ?> and <?php echo esc_html( $stats['reply_count'] ); ?> but this code doesn’t work on my home page.
    Why is that?

    #161040
    andrew55
    Participant

    I recently moved our bbPress installation from one folder to another. Everything seemed to go well, accept when I loggged in, my admin account lost all admin privileges.

    Fortunately, I have another second test bbPress installation and could see what admin status looks like in phpmyadmin.

    So, in the first installation, using phpmyadmin, in the metavalue of the wp_usermeta table, I changed:

    a:2:{s:10:"subscriber";i:1;s:15:"bbp_participant";b:1;}

    to…

    a:2:{s:13:"administrator";b:1;s:13:"bbp_keymaster";b:1;}

    It seems to work. My admin account has admin privileges.

    Now I understand the administrator and bbp_keymaster in the string, but what about the rest of the characters? For example, I changed s:10 to s:13.

    Is this OK?

    I’m just not sure what these other characters mean and what they need to be.

    Thanks for any help.

    #161037
    sndstrm
    Participant

    I already coded a private bbPress Plugin, that extends it to something like Mailman.
    It just periodically catches mails to @forum.domain.tld via IMAP and adds a new reply to the topic with the Mail content (quotation skipped).
    The notification is tweaked: the Reply-To header is replaced by reply-[topic-id]@forum.domain.tld, so the user can easily reply to the topic. But this is currently done by completely replacing the bbp_notify_topic_subscribers function with my own one (including the original content, just replacing the Reply-To).
    All calls to bbp_subscription_mail_headers and bbp_subscription_from_email or bbp_subscription_to_email are just called with $headers or the address itself. As of 1.5.6 the Reply-To is no longer set by bbPress.

    Will there be a way to include the topic-id (preferred in header altering) in upcoming releases? Or maybe a solution by bbPress itself to respond to notification Mails?

    xenous
    Participant

    you can configure the noreply email simply with:

    
    add_filter('bbp_get_do_not_reply_address','my_bbp_no_reply_email');
    function no_reply_email(){
        $email = 'noreply@yourdomain.com';
        return $email;
    }

    bbPress uses BCC for sending subscription emails and the noreply email is used as to field. This is for better hardware (cpu and memory) usage as if you were to loop each user subscribed to content it would be troublesome.
    you can change that default to email address as well with :

    
    add_filter('bbp_subscription_to_email','my_bbp_subscription_to_email');
    function my_bbp_subscription_to_email(){
        $email = 'noreply@yourdomain.com'; // any email you want
        return $email;
    }

    I hope this helps.

    #161013
    Robkk
    Moderator
    #161004
    Robkk
    Moderator

    @katootje Robin forgot he already had this type of functionality in one of his other plugins.

    bbp additional shortcodes

    #160999
    Robkk
    Moderator

    @casnbug

    its definitely something wrong with the freshness link just cant tell if a code snippet could be affecting the code or what.

    you can go through the basic troubleshooting for general issues by following this post

    Before Posting

    Robkk
    Moderator

    @digitalninjaza

    this should do what your talking about

    function rk_topic_description() {
    	    	echo bbp_topic_excerpt();
    }
    
    add_action('bbp_theme_after_topic_title','rk_topic_description');
Viewing 25 results - 8,951 through 8,975 (of 32,505 total)
Skip to toolbar