ms_model_relationship_create_ms_relationship_before

Create a new membership relationship.

Description

(MS_Model_Relationship) do_action( 'ms_model_relationship_create_ms_relationship_before', (int) $membership_id, (int) $user_id, (string) $gateway_id, (int|string) $move_from_id ); 

Search for existing relationship (unique object), creating if not exists. Set initial status.

Returns (MS_Model_Relationship)

The created relationship.

Parameters (4)

0. $membership_id (int)
The Membership to subscribe to.
1. $user_id (int)
The user who subscribes to the membership.
2. $gateway_id (string)
The gateway which is used for payment.
3. $move_from_id (int|string)
A list of membership IDs to cancel on payment. This property is handled by the MS_Model_Invoice class.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'ms_model_relationship_create_ms_relationship_before', $membership_id, $user_id, $gateway_id, $move_from_id ); 
The following example is for adding a hook callback.
  1. // define the ms_model_relationship_create_ms_relationship_before callback 
  2. function action_ms_model_relationship_create_ms_relationship_before( $membership_id, $user_id, $gateway_id, $move_from_id ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'ms_model_relationship_create_ms_relationship_before', 'action_ms_model_relationship_create_ms_relationship_before', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'ms_model_relationship_create_ms_relationship_before', 'action_ms_model_relationship_create_ms_relationship_before', 10, 4 ); 

Defined (1)

The action is defined in the following location(s).

/app/model/class-ms-model-relationship.php  
  1. do_action(