Skip to:
Content
Pages
Categories
Search
Top
Bottom

Set default status of new groups to ‘Hidden’ upon creation


  • studiostekker
    Participant

    @studiostekker

    I’m trying to create a network where people ‘register’ for the services by submitting a Group. After the group is submitted, an invoice will be sent manually, and after it gets paid, the admin will manually change the Group to Public.

    I’ve used this code snippet to skip the Group Settings Page when users submit their group (I don’t want them to be able to change it themselves).

    But now, I’m trying to force all new Groups to be Hidden instead of the default value Public. I’ve edited the create.php, but that does not seem to work, I guess because the Group Settings page gets skipped. Is there a different way to set the default value to Hidden?

    Kind regards,

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

  • shanebp
    Moderator

    @shanebp

    Why not just add the status parameter to your code ?

    'position'   => 0,
    'status' => 'hidden'

    Venutius
    Moderator

    @venutius

    I’ve not tried this but looking at the codebase there’s a filter that will filter the group attributes immediately before save, meaning new groups should always be hidden if you want to make it that way.

    Try this:

    add_filter( 'groups_group_before_save', venutius_make_new_group_hidden' )
    
    function venutius_make_new_group_hidden( $group_ref_array ) {
       if ( current_user_can( 'manage_options' ) ) {
            return $group_ref_array; //let admin set any group status
        }
    
        $group_ref_array->status = 'hidden';
    
        return $group_ref_array;
    }

    Let me know if it works


    Venutius
    Moderator

    @venutius

    Two options!


    studiostekker
    Participant

    @studiostekker

    Thank you kindly the both of you! Works like a charm.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar