BuddyDev

Search

[Resolved] Mediapress status order

Tagged: ,

  • Participant
    Level: Enlightened
    Posts: 21
    Axel on #15157

    Hi, is it possible to change the status order from default to

    public
    loggedin
    friends only
    private

    Thanks for your help 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #15159

    Hi Axel,
    Here is a future proof way to do it

    
    
    /**
     * Reorder status in the dropdown.
     *
     * @param array $statuses statuses.
     *
     * @return array
     */
    function mpp_custom_status_order( $statuses ) {
        // the ordered list, knowm.
    	$ordered_statuses = array( 'public', 'loggedin', 'friendsonly', 'loggedin', 'private' );
    
    	// we will organize the list here.
    	$new_ordered_statuses = array();
    
    	// Copy all valid status based on the ordered status. It only copies the statues specified by the ordered list.
    	foreach ( $ordered_statuses as $ordered_status ) {
    		if ( isset( $statuses[ $ordered_status ] ) ) {
    			$new_ordered_statuses[ $ordered_status ] = $statuses[ $ordered_status ];
    		}
    	}
    
    	// now, some other values might still be remaining.
    	$remaining_statues = array_diff( array_keys( $statuses ), $ordered_statuses );
    
    	foreach ( $remaining_statues as $remaining_key ) {
    		$new_ordered_statuses[ $remaining_key ] = $statuses[ $remaining_key ];
    	}
    
    	return $new_ordered_statuses;
    }
    
    add_filter( 'mpp_get_editable_statuses', 'mpp_custom_status_order' );
    
    

    It might be even easier in future when we add the support for Sortable interface.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 21
    Axel on #15167

    That worked. Thanks Brajesh. 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #15173

    Thank you for confirming.

The topic ‘ [Resolved] Mediapress status order’ is closed to new replies.

This topic is: resolved