Skip to content

Is there a hook that lets me filter the original long url that the user enters? #2890

Answered by ozh
Spatino19 asked this question in Q&A
Discussion options

You must be logged in to vote

The function called when shortening a new URL is yourls_add_new_link()

Here, there isn't indeed a straightforward $url = yourls_apply_filter("some_hook", $url);
That might be added, for instance after the yourls_do_action( 'pre_add_new_link', $url, $keyword, $title ); to filter the submitted URL, keyword and title.

An easy alternative is to hook to one of the numerous filters already called within this function or within functions called by this function (for instance yourls_sanitize_url() ...)

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@luanfernandes
Comment options

@Spatino19
Comment options

@ozh
Comment options

ozh Apr 8, 2021
Maintainer

@Spatino19
Comment options

@luanfernandes
Comment options

Answer selected by ozh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants