• Constellation Client Portal Hooks – Filters

    Constellation Client Portal Hooks

    Filters

    Invoice Filters

    Filter: ‘accp_define_invoice_statuses’

    Parameters: $statuses An array of current invoice statuses.

    Description: This filter allows invoice statuses to be added, edited, or removed.

    Note: If you have a status assigned to existing invoices, then subsequently remove that status via this hook, the invoices will still have the previous status stored to the post, but the incorrect status will show in the status select field within the invoice.

    Note: If you choose to remove default statuses, voided, refunded, and write-off are the only default statuses that can be removed. The paid and unpaid statuses cannot be removed.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_define_invoice_statuses', 'yourprefix_update_defined_invoice_statuses', 10, 1);
    function yourprefix_update_defined_invoice_statuses($statuses){
    
         //Add a new invoice status.
         $statuses['new-status'] = 'New Status'; //Change "new-status" and "New Status."
    
         return $statuses;
    
    }
    
    

    Filter: ‘accp_update_invoice_prohibited_product_types’

    Parameters: $prohibited_product_types An array of prohibited product type slugs ( ex. array(‘variable, ‘variable-subscritpion’) ).

    Description: This filter allows the default list of prohibited product types to be edited to account for additional product type exclusions that might be needed after installing a plugin (or other customizations that you might need). This list prevents defined product types from showing in the product select field within invoices, and is intended to remove product types that cannot be added to the cart correctly via the WooCommerce add-to-cart URL param. As an example, it’s usually not a good idea to add a parent product ID to an add-to-cart link (in the case of variable products), but instead the specific product variation ID should be added.

    Filter: ‘accp_invoice_already_added_text’

    Parameters: $message_text String – The default message text.

    $invoices_in_cart Array – An array of invoice post ID’s to be paid.

    Description: This filter allows the default “Item already added” text (that appears beside pay buttons after an item is added to the cart) to be changed.

    Filter: ‘accp_invoice_already_added_link_text’

    Parameters: $link_text String – The default links text.

    $invoices_in_cart Array – An array of invoice post ID’s to be paid.

    Description: This filter allows the default “Proceed to payment” link text (that appears beside pay buttons after an item is added to the cart) to be changed.

    Filter: ‘accp_update_no_assigned_product_total’

    Parameters: $no_assigned_product_total A number (accepts a number with two decimal places).

    Description: This filter allows the invoice total to be set for invoices that do not have any products assigned (which makes the default invoice total null). This can be useful in cases where you may want to explicitly display an invoice total of “0.00” without having to create a product with a price of 0.00 and assign it to the invoice.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_update_no_assigned_product_total', 'yourprefix_update_no_product_invoice_total', 10, 1);
    function yourprefix_update_no_product_invoice_total($no_assigned_product_total){
    
         //The value must be a number (float) which accepts two decimal places.
         $no_assigned_product_total = 0.00;
    
         return $no_assigned_product_total;
    
    }
    
    

    File Filters

    Filter: ‘accp_define_file_statuses’

    Parameters: $statuses An array of current file statuses.

    Description: This filter allows file statuses to be added, edited, or removed.

    Note: If you have a status assigned to existing files, then remove that status via this hook, the files will still have the previous status stored to the post, but the incorrect status will show in the status select field within the file.

    Note: If you choose to remove default statuses, na, in-progress, and incomplete are the only default statuses that can be removed. The completed status cannot be removed.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_define_file_statuses', 'yourprefix_update_defined_file_statuses', 10, 1);
    function yourprefix_update_defined_file_statuses($statuses){
    
         //Add a new file status.
         $statuses['new-status'] = 'New Status'; //Change "new-status" and "New Status."
    
         return $statuses;
    
    }
    
    

    Global File Filters

    Filter: ‘accp_define_global_file_statuses’

    Parameters: $statuses An array of current global file statuses.

    Description: This filter allows global file statuses to be added, edited, or removed.

    Note: If you have a status assigned to existing global files, then subsequently remove that status via this hook, the files will still have the previous status stored to the post, but the incorrect status will show in the status select field within the file.

    Note: If you choose to remove default statuses, na, in-progress, and incomplete are the only default statuses that can be removed. The completed status cannot be removed.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_define_global_file_statuses', 'yourprefix_update_defined_global_file_statuses', 10, 1);
    function yourprefix_update_defined_global_file_statuses($statuses){
    
         //Add a new file status.
         $statuses['new-status'] = 'New Status'; //Change "new-status" and "New Status."
    
         return $statuses;
    
    }
    
    

    Filter: ‘accp_update_allowed_post_types_for_global_files’

    Parameters: $default_post_types An array of current global file allowed default post types.

    Description: This filter allows global file default post types to be added, edited, or removed. Post type slugs listed in the $default_post_types will allow the accp_global_files shortcode to be embedded and displayed on pages and posts of each of those post types.

    Note: If you choose to add additional post types to the $default_post_types you should verify that your posts and attachments are secure on those pages, before making any changes live to site users.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_update_allowed_post_types_for_global_files', 'yourprefix_update_allowed_post_types_for_global_files', 10, 1);
    function yourprefix_update_allowed_post_types_for_global_files($default_post_types){
    
         //Add a new post type slug.
         $default_post_types[] = 'new-post-type-slug'; //Change "new-post-type-slug".
    
         return $default_post_types;
    
    }
    
    

    Invoice and File Filters

    Filter: ‘accp_past_due_text’

    Parameters: $past_due_text String – The default past due text.

    $item_id Integer – the post ID of the invoice or file. This can be used to differentiate between file and invoice post types (by checking the post type), as an example.

    Description: This filter allows the default “past due” text in past due notifications to be changed.

    Login Filters

    Filter: ‘accp_update_login_redirect_url ‘

    Parameters: $redirect_to A valid URL to redirect to.

    Parameters: $request The requested redirect destination URL passed as a parameter. See the WordPress login_redirect filter for more information.

    Parameters: $user The WP user object. See the WordPress login_redirect filter for more information.

    Description: This filter allows for the login redirect URL to be changed.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter('accp_update_login_redirect_url', 'yourprefix_change_login_redirect_url', 10, 3);
    function yourprefix_change_login_redirect_url($redirect_to, $request, $user){
         
         // URL of the page to redirect to.
         $redirect_to = 'https://your-site/new-page-name';
    
         return $redirect_to;
    
    }
    
    

    Client Page Filters

    Filter: ‘accp_update_client_pages_slug’

    Parameters: $default_slug The default URL rewrite name/slug (string) of the client page post type.

    Description: This filter allows the default URL rewrite slug (“accp-client-page”) to be changed.

    Note: Any new slug name that you choose must be unique (i.e. not already in use by another post type), and must only be comprised of alphanumeric characters, hyphens, and/or underscores.

    Note: If there is already an override rewrite slug entered in the plugin settings (WP Admin -> Client Portal Pro -> Settings -> General Settings -> Override the Client Page URL Base Name) the value in the settings will supersede this filter.

    Example

    The following would be placed in functions.php within your theme.

    
    
    add_filter( 'accp_update_client_pages_slug', 'accp_change_accp_client_pages_slug', 10, 1 );
    function accp_change_accp_client_pages_slug( $default_slug ) {
    
    	/**
    	 * Change the $new_slug value "new-name"
    	 * to the value that you would like to set
    	 * the new name to.
    	 * 
    	 * IMPORTANT
    	 * 
    	 * The name must be all lower case with no spaces,
    	 * and *must* be unique (i.e. not in use by any other post type).
    	 * 
    	 * IMPORTANT
    	 * 
    	 * After implementing this, the rewrite rules must be flushed
    	 * for the changes to take effect.  This can be done by navigating
    	 * to WP Admin -> Settings -> Permalinks, then click the
    	 * "Save Changes" button to flush the rewrite rules.
    	 */
    	$new_slug = 'new-name'; // Change this value.	
    
    	return $new_slug;
    
    }
    
    
    ARS