Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a group via WP_Admin

  • Avatar of hunnie
    Hunnie
    Participant

    @hunnie

    I have a requirement to only allow group creation from the wp-admin.

    the wp-admin/groups/index page ‘Add New’ button takes us to the front end /groups/create page.

    I don’t want to amend core files does anybody have any pointers as to how I can achieve this?

    I have tried to redirect (for the moment to the edit page as a test) but this is failing and always takes me to the front-end create page:

    add_action('init', 'rewrite_admin_group_create');
    function rewrite_admin_group_create() 
    {
       global $wp_rewrite;
    
       $wp_rewrite->add_rule('groups/create/', 'wp-admin/admin.php?page=bp-groups&action=edit&gid=2','top');
       $wp_rewrite->flush_rules(false);  
    }

    I’m using WP: 3.8.1 and BP: 1.9.1

    tia

Viewing 1 replies (of 1 total)
  • Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    I don’t know the solution to the question, but I saw your code — don’t call flush_rules() on every page load. It will seriously slow down your site. You don’t need it at all, since you’re adding the same rule on every page load. (You can go to wp-admin > Settings > Permalinks which will force WP to clear the rewrite rules cache).

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.