Skip to:
Content
Pages
Categories
Search
Top
Bottom

Trouble adding customized redirect in functions

  • Hello! First of all, love the the plugin! I’ve been searching for this ALL day! Literally.

    So everything is well except I’m having trouble creating an alternate redirect page for users not logged in.

    I added the:

    ` function redirect_nonloggedin_users($current_uri, $redirect_to) {
    // Redirect users to the homepage
    // Caution! Exclude the homepage from ‘Private BuddyPress’ options
    // to avoid redirection loops!
    return get_option(‘siteurl’) . ‘/?from=’ . $redirect_to;
    }

    add_filter(‘pbp_redirect_login_page’, ‘redirect_nonloggedin_users’, 10, 2); `

    Code verbatim to a fresh functions.php page, but with no luck. I replace the ‘siteurl’ with http://www.mysite.com/register as I want it to redirect to the buddypress registration page instead of the wp login page.

    Am I doing something wrong? Should there be any other code in the functions page to make it work? Does the url go somewhere else or need to be formatted differently?

    Thanks in advance for all of your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Just from looking at your function, you didn’t put the url in the correct location, as specified on the first line’s $redirect_to.

    On the line: return get_option(‘siteurl’) . ‘/?from=’ . $redirect_to;

    Try `$redirect_to=’URL’;`

    If it does not work, you could be missing some other needed function calls, I don’t use this plugin.

    SVC, Tried that and unfortunately it didn’t work. Thanks for trying to help, hopefully I can find a solution before the night is over.

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    As I said, you could be missing some other needed function calls, I don’t use this plugin :)

    Hi pargie! i think the solution is:

    `return get_option(‘siteurl’) . ‘/register’ . ‘/?from=’ . $redirect_to;`

    try it… hope it works!

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

You must be logged in to reply to this topic.