barnabe (@barnabe)

Forum Replies Created

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

  • barnabe
    Participant

    @barnabe

    But with this code, when there is an error (like username already exists), the redirect is not effective.

    This excellent tutorial helped me to fix that : Redirect to custom page after login or register fails


    barnabe
    Participant

    @barnabe

    – How to hide the WP toolbar by default when a user registers?

    I found this code to add in functions.php theme file:

    add_filter('show_admin_bar', '__return_false');

    – I use the bbPress’ form register template, how to redirect users to a specific page after submit and not to the WP’s form login?

    I found this code to add in functions.php theme file:

    function bbp_form_register_custom_redirect()
    {
       return 'URL here'; // Ex : return get_permalink(73);
    }
    
    add_filter('bbp_user_register_redirect_to', 'bbp_form_register_custom_redirect');

    But with this code, when there is an error (like username already exists), the redirect is not effective.

    Any idea?


    barnabe
    Participant

    @barnabe

    Maybe this bug not appears if bbPress is installed before qTranslate. I’ll try an another install to test that.

    Finally, even if bbPress is intalled before qTranslate, qTranslate is loaded first.


    barnabe
    Participant

    @barnabe

    Hello,

    Thanks for the answer! In fact, this is no a display problem in admin menu, but rights (user capabilities). When I set the URL “edit.php?post_type=forum” directly in the addresses’ bar, WordPress says to me I have not the right to access this page.

    After a “very” long debug, I found why this behavior appends. The qTranslate plugin is loaded before bbPress and sets up the WP_User via the function wp_get_current_user() and so sets its allcaps. So when WordPress object is init in wp-settings.php file to sets up current user, wp_get_current_user() returns the existing user and not reloads capabilities.

    I fixed this problem in adding a param to wp_get_current_user():

    function wp_get_current_user($new_user = false){}

    and the same param to get_currentuserinfo() and wp_set_current_user(). I also modified the condition in get_currentuserinfo():

    if ( ! empty( $current_user ) && $new_user === false ) {

    and the condition in wp_set_current_user():

    if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) && $new_user === false )

    Then I added the true value in param to the call of wp_get_current_user() in init method of WP class.

    Maybe this bug appears because I installed qTranslate before bbPress. Maybe this bug not appears if bbPress is installed before qTranslate. I’ll try an another install to test that. It would be nice not to change the core of WordPress.

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