Skip to:
Content
Pages
Categories
Search
Top
Bottom

Allowing only $content with urls to be posted(Error)

  • @impartialintel

    Participant

    Hi I ran into an error and it would be nice if someone could help me. The error has something to do with the args that are passed. It’s an ‘Uncaught ArgumentCountError: Too few arguments to function bp_require_link_in_activity(), 1 passed’ Error.
    The Code goes like this:

    function bp_require_link_in_activity( $content, $user_id , $type = null, $item_id = null , $secondary_item_id = null, $component = null , $action = null, $recorded_time = null, $hide_sitewide = null ) {
    if ( ! preg_match( ‘/https?:\/\/\S+/i’, wp_strip_all_tags( $content ) ) ) {
    bp_core_add_message( ‘Gültigen Link eintragen.’, ‘error’ );
    return false;
    }

    return $content;

    }
    add_filter( ‘bp_activity_before_save’, ‘bp_require_link_in_activity’, 10, 9 );

    Thanks in advance

Viewing 1 replies (of 1 total)
  • @emaralive

    Participant

    Hi @impartialintel,

    You seem to be confused between Actions vs Filters. Additionally, bp_activity_before_save is clearly an Action as can be seen by the following:

    
    do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
    

    The reason you are receiving the error message is because the aforementioned action is only passing 1 (one) argument $this (object) while your callback is expecting 9 (nine) arguments thus, there are “Too few arguments to function bp_require_link_in_activity(), 1 passed” as the error message has indicated.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar