Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] shortcode for user counter #114

Open
valessiobrito opened this issue Jun 11, 2021 · 5 comments
Open

[feature request] shortcode for user counter #114

valessiobrito opened this issue Jun 11, 2021 · 5 comments

Comments

@valessiobrito
Copy link

valessiobrito commented Jun 11, 2021

A code which can show the total number of users in a segment or tag, or platform total.

Inspired in https://wordpress.org/plugins/contacts-in-mautic/

Eg.

[mautic tagscount=2]

[mautic segmentcount=1]

[mautic contactscount]


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@shulard
Copy link
Collaborator

shulard commented Oct 4, 2021

Hello !

This seems an interesting idea, if you want to contribute, I'll be glad to review your code ^^

@weismannweb
Copy link

im willing do this, when i find time

@weismannweb
Copy link

weismannweb commented Nov 25, 2021

So i was thinking of:

I think this can ALL be done with this mautic api call and ONE wordpress shortcode:
https://developer.mautic.org/#list-contacts

[mautic type="contacts" search="thesearchstring" display="list" limit="10" where="where_x=y|where_x=y|where_x=y|where_x=y|where_x=y" orderBy="first_name" orderbydir="desc"]

[mautic type="contacts" search="thesearchstring" display="count" where="where_x=y|where_x=y|where_x=y|where_x=y|where_x=y" orderBy="first_name" ]

I would extrapolate that one shortcode and function to create these shorter shortcodes but that one function above would handle these too:

[mautic type="tags" display="list" ids="2.4,6" limit="10" ...]
[mautic type="segment" display="list" ids="2.4,6" limit="10" ...]
[mautic type="tags" display="count" ids="2.4,6" ...]
[mautic type="segment" display="count" ids="2.4,6" ...]
[mautic type="points" display="count"]

ids: can be id or name (if api call supports both)

Have a default style and allow developers to use a template include wp hook to change the style.

Finally too boot lets allow this function I create to return an array for developers who want to use it:

function mautic_search(,,,,,,,,,,,$return_type)

The only crappy part of this, correct me if im wrong, is I think we need to have an oauth 2.0 authentication feature to do this. The shortcode is quite simple but oauth is a ui feature and a 3 step process plus a cron to keep the token fresh.

FYI, I assume this is what can be done with that api call search param:
Search Operators:

  • (plus sign) - Search for the exact string (i.e. if admin, then administrator will not match)
    ! (exclamation mark) - Not equals string
    " " (double quotes) - Search by phrase
    ( ) (parentheses) - Group expressions together.
    OR - By default the expressions will be joined as AND statements. Use the OR operator to change that.
    % - Use the % as a wildcard to search for specific names or values in a phrase (i.e. to find all companies with the word ‘Technologies’ then type %technologies%)

Search commands
is:anonymous
is:unowned
is:mine
email:*
segment:{segment_alias}
name:*
company:*
owner:*
ip:*
ids:ID1,ID2 (comma separated IDs, no spaces)
common:{segment_alias} + {segment_alias} + ...
tag:*
stage:*
email_sent:EMAIL_ID
email_read:EMAIL_ID
email_queued:EMAIL_ID
email_pending:EMAIL_ID

@shulard
Copy link
Collaborator

shulard commented Nov 25, 2021

Ok, this looks good. However, the main point is not implementing the Shortcode for me. If we introduce this feature, we'll require to add an HTTP client to communicate with the Mautic API. That's my main concern here, today we don't use this API in the plugin so be careful if you work on an implementation to clearly decouple the API call from the code itself.

@weismannweb
Copy link

weismannweb commented Nov 25, 2021

I decouple/loosely couple everything I do lol. I can implement a simple api call using curl. I don't even need to introduce a dependency. The oauth part is the part im not sure how to decouple. I was actually thinking of creating a seperate oauth authentication plugin for all wordpress devs who need it. Then have hooks for devs to use it. We could do that and require this for that plugin to work? Seems a bit obtuse to do that. So maybe if you want to keep it totally separate I can make this another plugin for your plugin and have both oauth and this search in that new child plugin and we can maintain it separately? I may need a single hooks from you to get it done such as grabbing the mautic url but i will use it only if your plugin is installed....otherwise i will have my own mautic url field too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants