How do redirect to multisites "add new product page"

Hi,

i want redirect all new signups and logins for multisites to "add new product page" is this possible? and if yes what is the url i should use? as all sub-sites have diffrent url.

  • DavidM
    • DEV MAN’s Mascot

    Hi Erik,

    That'd normally be a matter of custom development but fortunately Mason's posted a snippet in the following thread (courtesy of dsader), that lets you redirect users to their own blog upon login:
    https://premium.wpmudev.org/forums/topic/redirect-users-to-their-blogs-homepage

    And I believe you can alter that slightly as follows to take you to the Add New Product page:

    <?php
    function ds_login_redirect( $redirect_to, $request_redirect_to, $user )
    {
        if ($user->ID != 0) {
            $user_info = get_userdata($user->ID);
            if ($user_info->primary_blog) {
                $primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/post-new.php?post_type=product';
                if ($primary_url) {
                    wp_redirect($primary_url);
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);
    ?>

    You can create a new file, name it something like 'my_login_redirect.php' as Mason mentions, and drop it in your /mu-plugins/ folder. It should just work from there.

    How would that work for ya?

    -David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.