Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 1,826 through 1,850 (of 2,756 total)
  • @henrywright

    Moderator

    Unless you’ve created bp-custom.php yourself, you won’t have one.

    If you can verify that you’re using Twenty Fifteen, no plugins activated, and have made no custom code changes, then please feel free to open a ticket on Trac. Please provide the developers with as much info as you can (see here) and describe the problem you’re seeing in as much detail as you can. Also, feel free to reference this thread.

    @henrywright

    Moderator

    Do you have a bp-custom.php file? Can you make sure to remove any custom code you have in that file if you have created it?

    @henrywright

    Moderator

    @ouegy you wrote the function, so the credit is all yours! 🙂

    @henrywright

    Moderator

    @casesolver

    The error log seems to indicate the problem is coming from the theme x. For example:

    wp-content/themes/x/framework/functions/global/plugins/buddypress.php on line 478

    Can you try reverting to the Twenty Fifteen theme to see if the issue is resolved?

    @henrywright

    Moderator

    Also, if you wanted to condense your function into less statements, you could use the set_role() method instead of remove_role() and add_role(). See here

    @henrywright

    Moderator

    I’m not using s2member so can’t test your function. However, I think you’re almost on the right track. One thing I noticed was your use of $user->ID. I don’t see where you’re getting the $user object from? You might need to use get_current_user_id() instead. Try:

    <?php
    
    add_action( 'xprofile_avatar_uploaded', 'update_membership_level' );
    
    function update_membership_level() {
    
    	$u = new WP_User( get_current_user_id() );
            // Remove role
            $u->remove_role( 's2member_level1' );
    
            // Add role
            $u->add_role( 's2member_level2' );
    
    	}
    	
    ?>

    @henrywright

    Moderator

    Try deactivating all plugins to see if the problem resolves itself. Perhaps deactivate them one-by-one, checking each time. The idea is to find out what piece of code has introduced the problem.

    @henrywright

    Moderator

    …is there some sort of event hook that could fire on this to change the user’s role eg. make them a full member (level_2)

    Yes. That’d be xprofile_avatar_uploaded. It fires immediately after the new avatar is processed.

    @henrywright

    Moderator

    Which plugins do you have installed?

    @henrywright

    Moderator

    Hi @chcsuter

    Do @-mentions work with the Twenty Fifteen theme activated?

    @henrywright

    Moderator

    Hi @casesolver

    Provider says it is because it’s in remote

    Can you ask them to clarify what they mean by this?

    @henrywright

    Moderator

    There’s a lot more to uploading an avatar than just saving the meta. Check out xprofile_screen_change_avatar() to see how BuddyPress handles the process.

    Along with saving meta info, you’ll need to handle the actual file and save it to your file system (just as BuddyPress does). Then there’s cropping to think about too.

    Hope this info helps.

    @henrywright

    Moderator

    Hi @ouegy

    How are you saving the actual file to your file system?

    @henrywright

    Moderator

    Hi @mvaneijgen

    Take a look at the BuddyPress Template Hierarchy article. It explains how BuddyPress will look for specific template files inside your theme if you’ve created them. These then override the default.

    In reply to: Pre loading members

    @henrywright

    Moderator

    The wp_users table description can be found here:

    https://codex.wordpress.org/Database_Description

    And here’s the BuddyPress database diagram:

    BuddyPress Database Diagram

    Hope that helps you.

    @henrywright

    Moderator

    Try using the Twenty Fifteen theme and then deactivating all plugins one-by-one. The idea is to find out which piece of code is introducing the problem.

    In reply to: avatar does not show

    @henrywright

    Moderator

    OK, now with Twenty Fifteen activated, try deactivating all plugins you have installed and remove any custom code you may have in your bp-custom.php file (if you have one).

    In reply to: Pre loading members

    @henrywright

    Moderator

    Hi @alexbotkin

    I’m not aware of an Excel importer. Perhaps try searching the WordPress Plugin Directory for one.

    @henrywright

    Moderator

    Right. In that case, you can just modify the output of your for loop. For example:

    for ( $i = 0; $i < $sportsSize; $i++) {
    
        // For this particular $i, get the URL here and store it in a $url variable. You may need to query the db again? i.e. where will you get the URL from, or where are you storing it?
    
        $femaleSport = $wpdb->get_var( "SELECT COUNT(user_id) FROM ar_bp_xprofile_data WHERE value = 'female' AND user_id IN (SELECT user_id FROM ar_bp_xprofile_data WHERE value = '" . $sports[$i] . "')" );
    
        if ($femaleSport != 0) {
            // Update the output of the loop to include hyperlink markup.
            echo '<p><a href="' . $url . '">' . $sports[$i] . ' (' . $femaleSport . ')</a></p>';
            $femaleCounter++;
        }
    }

    @henrywright

    Moderator

    If you look at my snippet here, you will see that I’ve hooked the my_set_default_member_type() function to bp_core_signup_user. Now, bp_core_signup_user fires each time a new user registers on your website. This means that bp_set_member_type( $user_id, 'student' ) executes each time a new user registers on your site.

    Then if you look here, you’ll see I’ve hooked my youmin_set_role() function to the bp_set_member_type hook (note that the bp_set_member_type hook and the bp_set_member_type() function are different things). This means that when the bp_set_member_type hook fires, the code inside youmin_set_role() will execute.

    So as you can see, you have to use both snippets together, exactly as I’ve written them, in order for things to work.

    @henrywright

    Moderator

    Hi @youmin

    My post was this:

    Just to point out, you can’t use or in PHP. Instead you should use a double pipe like this ||.

    This is wrong! You can in fact use the or operator in PHP, it just takes a lower precedence than ||.

    Hence why I deleted my post.

    Hope that clears things up.

    @henrywright

    Moderator

    Hi @youmin

    If you don’t already have your roles set-up then this is how you’d add them:

    add_role(
        'student',
        __( 'Student' ),
        array(
            'read'         => true,  // true allows this capability
            'edit_posts'   => true,
            'delete_posts' => false, // Use false to explicitly deny
        )
    );

    The 3rd parameter is where you’d put your capabilities. In my example above, I’ve created a ‘student’ role which can read and edit posts but can’t delete posts. Feel free to amend these capabilities.

    Ref: https://codex.wordpress.org/Function_Reference/add_role

    Then to pick up on Boone’s suggestion in the Trac ticket, you could do this:

    function youmin_set_role( $user_id, $member_type, $append ) {
        $userdata = array( 'ID' => $user_id, 'role' => $member_type );
        wp_update_user( $userdata );
    }
    add_action( 'bp_set_member_type', 'youmin_set_role', 10, 3 );

    When you use the bp_set_member_type() function like I have done here, this code will assign a role to the user who is signing up. The role that is assigned will be the type you use in bp_set_member_type().

    Hope this helps you.

    @henrywright

    Moderator

    Hi @barodscheff

    Can you clarify exactly what you’d like to link and where you’d like to link to?

    @henrywright

    Moderator

    You’ll need to switch to the default theme (let’s say Twenty Fifteen) to see if that works. Also, deactivate your plugins one by one. The idea is to isolate the issue (work out which plugin is introducing the problem)

    @henrywright

    Moderator

    Which theme and plugins are you using?

Viewing 25 replies - 1,826 through 1,850 (of 2,756 total)
Skip to toolbar