API > Users

Basic JavaScript object

Membership.api.users

getActivity

Gets list of activity for the certain user.

Parameters

  • userId
    ID of a user for which you need to get activity
  • limit
    Maximum number of activity which has to be returned. By default 5, minumum value 1, maximum value 20.
  • offsetId
    ID of activity regarding to which is needed to get activity in descending order.

Result

After success returns object which contains request status in success property and template render in html property

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Activity/views/activites.twig with specified user in request.

Example

Membership.api.users.getActivity({
    userId: 1,
    limit: 5,
    offsetId: null
});

addFriend

Creates friend request and subscribes to user.
Or subscribes and accepts friend request if the user ID has sent the same request to this user.

Parameters

  • userId
    ID of a user to which is needed to send request or accept request from the user.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig
  • message
    Error message in a case of unsuccessful request.
  • status
    Status code of HTTP

Example

Membership.api.users.addFriend({
    userId: 1
});

removeFriend

Removes user from the friend list or cancels friend request.

Parameters

  • userId
    ID of a user who had to be removed from the friend list or whose friend request has to be cancelled.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error..
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig
  • message
    Error message in a case of unsuccessful request.

Example

Membership.api.users.removeFriend({
    userId: 1
});

getFollows

Returns list of users who are followed by user.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.

Result

Returns object with success and html properties:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig

Example

Membership.api.users.getFollows({
    userId: 1,
    limit: 10,
    offsetId: null,
    search: 'John'
});

getFollowers

Returns list of users who are subcribed to a user.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.

Result

Returns object with success and html properties:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig

Example

Membership.api.users.getFollowers({
    userId: 1,
    limit: 10,
    offsetId: null,
    search: 'John'
});

follow

Subscribes to specified user.

Parameters

  • userId
    ID of a user to subscribe.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message, status.

  • success
    Request status true if successful or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig
  • message
    Error message in a case of unsuccessful request.
  • status
    Status code of HTTP

Example

Membership.api.users.follow({
    userId: 1
});

unfollow

Unsubscribes from specified user.

Parameters

  • userId
    ID of a user from which is needed to unsubscribe.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig

Example

Membership.api.users.unfollow({
    userId: 1
});

Allows to search users by first and last name.

Parameters

  • query
    Request line
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 20.
  • offset
    Offset which is needed for selecting certain subset of users.
  • template
    Template with the help of which list a will be rendered.Acceptable values

    • users-list will be rendered membership-by-supsystic/src/Membership/Users/views/partials//partials/users-list.twig
    • search-dropdown will be rendered membership-by-supsystic/src/Membership/Base/partials/search-dropdown-user.twig

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials//partials/users-list.twig or membership-by-supsystic/src/Membership/Base/partials/search-dropdown-user.twig

Example

Membership.api.users.search({
    query: 'John',
    limit: 10,
    offset: 0,
    template: 'users-list'
});

get

Returns list of users, sorting order is specified in the plugin settings.

Parameters

  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 20.
  • offset
    Offset which is needed for selecting certain subset of users.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig

Example

Membership.api.users.get({
    limit: 10,
    offset: 0
});

changeCover

Changes cover of current user.

Parameters

  • attachmentId
    ID of uploaded image. Look at method uploadImage
  • cropDataObject with properties to crop an image.

    x: x-axis offset of cropped area

    y: y-axis offset of cropped area

    width: width of image cropped area

    height: height of image cropped area

Result

Returns onject which contains properties success and images

  • success
    Request status true in a case of success or false in a case of error.
  • images
    Image array of current user with types: cover, avatar and specified in the plugin settings sizes.

Example

Membership.api.users.changeCover({
    attachmentId: 100,
    cropData: {
        x: 0,
        y: 118,
        width: 1000,
        height: 375,
    }
})

removeCover

Removes cover of current user.

Result

Returns object which contains success property

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.users.removeCover();

changeAvatar

Canges avatar of current user.

Parameters

  • attachmentId
    ID of uploaded image. Look at method uploadImage
  • cropDataObject with properties to crop an image.

    x: x-axis offset of cropped area

    y: y-axis offset of cropped area

    width: width of image cropped area

    height: height of image cropped area

Result

Returns object which contains success property and images

  • success
    Request status true in a case of success or false in a case of error.
  • images
    Image array of current user with types: cover, avatar and specified in the plugin settings sizes.

Example

Membership.api.users.changeAvatar({
    attachmentId: 100,
    cropData: {
        x: 0,
        y: 118,
        width: 1000,
        height: 375,
    }
})

removeAvatar

Removes avatar of current user.

Result

Returns object which contains success property

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.users.removeAvatar()

saveField

Saves specified field with user information.

Parameters

  • fieldName
    Field name ID.
  • fieldName
    Value or array of values if the type field supports set of values.

Result

Returns object which contains success property

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.users.saveField({
    fieldName: 'first_name',
    fieldData: 'John'
})

getFriends

Returns list of user’s friends.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 20.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list.twig

Example

Membership.api.users.getFriends({
    userId: 1,
    limit: 10,
    offsetId: null,
    search: 'John'
});

getFriendshipRequests

Returns list of friend requests.

Parameters

  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 20.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/users-list-friend-requests.twig

Example

Membership.api.users.getFriendshipRequests({
    limit: 10,
    offsetId: null,
    search: 'John'
});

updatePrivacy

Updates user privacy settings

Parameters

  • privaciesSettings object which contains pairs settings name – value.Acceptable names of privacy settings.
    • view-about
    • view-friends
    • view-follow
    • view-followers
    • view-groups
    • post-activity
    • view-comments
    • post-comments
    • view-posts

    Acceptable values.

    • all-users
    • friends
    • friends-of-friends
    • only-me

Result

Returns object with properties success and message

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about successful change of settings or error message.

Example

Membership.api.users.updatePrivacy({
    privacies: {
       'view-friends': 'all-users',
       'view-follows': 'all-users',
       'view-followers': 'all-users',
       'view-groups': 'all-users',
       'post-activity': 'friends',
       'view-posts': 'only-me',
       'view-comments': 'all-users',
       'post-comments': 'all-users '
    }
});

changeEmail

Updates user email.

Parameters

  • email
    New email
  • password
    Current password.

Result

Returns object with properties success and message:

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about successful change of email or error message.

Example

Membership.api.users.changeEmail({
    password: 'secret',
    email: '[email protected]'
});

changePassword

Updates user password.

Parameters

  • password
    Current user password
  • newPassword
    New user password.
  • newPasswordConfirmation
    New password coinformation

Result

Returns object with properties success and message::

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about successful change of password or error message.

Example

Membership.api.users.changePassword({
    password: 'secret',
    newPassword: 'very-secret',
    newPasswordConfirmation: 'very-secret'
});

deleteAccount

Removes user account.

Parameters

  • password
    Current user password

Result

Returns object with properties success and redirect, or success and message in a case of error:

  • success
    Request status true in a case of success or false in a case of error.
  • redirect
    A link where user has to be redirected after deleting.
  • message
    Error message.

Example

Membership.api.users.deleteAccount({
    password: 'secret'
});

getPosts

Returns list of user’s posts.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of posts which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    Post ID regarding to which a list will be displayed in descending order.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/posts.twig

Example

Membership.api.users.getPosts({
    userId: 1,
    limit: 10,
    offsetId: null
});

getPosts

Returns list of user’s posts.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of posts which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    Post ID regarding to which a list will be displayed in descending order.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/posts.twig

Example

Membership.api.users.getPosts({
    userId: 1,
    limit: 10,
    offsetId: null
});

getComments

Returns list of user comments.

Parameters

  • userId
    User ID for which is needed to get a list.
  • limit
    Maximum number of commnets which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    Comment ID regarding to which a list will be displayed in descending order.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Users/views/partials/comments.twig

Example

Membership.api.users.getComments({
    userId: 1,
    limit: 10,
    offsetId: null
});

Categories
Latest Articles