Jump to content

Developer Documentation

core/MemberSync

What it is

A MemberSync extension allows your application an opportunity to perform actions when member accounts change. When members are deleted your application may need to remove data associated with the member, or when member's log out you may need to sync this state change to an external service. The MemberSync extension type provides several callback methods to accomplish these tasks.

How to use

When creating a MemberSync extension you need only use the methods that are relevant for your application. Any methods that are not relevant can be deleted. The possible methods are outlined below:

    /**
     * Member account has been created
     *
     * @param    $member    \IPS\Member    New member account
     * @return    void
     */
    public function onCreateAccount( $member )
    {
    
    }
    
    /**
     * Member has validated
     *
     * @param    \IPS\Member    $member        Member validated
     * @return    void
     */
    public function onValidate( $member )
    {
    
    }
    
    /**
     * Member has logged on
     *
     * @param    \IPS\Member    $member        Member that logged in
     * @param    \IPS\Http\Url    $redirectUrl    The URL to send the user back to
     * @return    void
     */
    public function onLogin( $member, $returnUrl )
    {
    
    }
    
    /**
     * Member has logged out
     *
     * @param    \IPS\Member        $member            Member that logged out
     * @param    \IPS\Http\Url    $redirectUrl    The URL to send the user back to
     * @return    void
     */
    public function onLogout( $member, $returnUrl )
    {
    
    }
    
    /**
     * Member account has been updated
     *
     * @param    $member        \IPS\Member    Member updating profile
     * @param    $changes    array        The changes
     * @return    void
     */
    public function onProfileUpdate( $member, $changes )
    {
    
    }
    
    /**
     * Member is flagged as spammer
     *
     * @param    $member    \IPS\Member    The member
     * @return    void
     */
    public function onSetAsSpammer( $member )
    {
        
    }
    
    /**
     * Member is unflagged as spammer
     *
     * @param    $member    \IPS\Member    The member
     * @return    void
     */
    public function onUnSetAsSpammer( $member )
    {
        
    }
    
    /**
     * Member is merged with another member
     *
     * @param    \IPS\Member    $member        Member being kept
     * @param    \IPS\Member    $member2    Member being removed
     * @return    void
     */
    public function onMerge( $member, $member2 )
    {
        
    }
    
    /**
     * Member is deleted
     *
     * @param    $member    \IPS\Member    The member
     * @return    void
     */
    public function onDelete( $member )
    {

    }

    /**
     * Email address is changed
     *
     * @param    \IPS\Member    $member    The member
     * @param     string        $new    New email address
     * @param     string        $old    Old email address
     * @return    void
     */
    public function onEmailChange( $member, $new, $old )
    {

    }

    /**
     * Password is changed
     *
     * @param    \IPS\Member    $member    The member
     * @param     string        $new    New password
     * @return    void
     */
    public function onPassChange( $member, $new )
    {

    }

As you can see there are several event-based methods available to perform actions when specific member account changes occur. The most common uses of a MemberSync extension are to update content author IDs to 0 when a member is deleted (or to delete their contributions), and to change a member ID to a different member ID in onMerge when two accounts are merged. It should be noted that if your application uses content items and defines a ContentRouter extension, your content item data is handled automatically.


  Report Document


×
×
  • Create New...