Support » Developing with WordPress » Disabling users registration requirement

  • Hi,

    What should I change in this file so user don’t need to be registered/logged in to do the action? Is it safe to delete this part?

    $attrs = is_user_logged_in()
    	? 'href="#" data-toggle="modal" data-target="#report-listing-modal"'
    	: sprintf( 'href="%s"', esc_url( \MyListing\get_login_url() ) );
    ?>

    Full code below. Thank you.

    <?php
    /**
     * <code>Report Listing</code> quick action.
     *
     * @since 2.0
     */
    if ( ! defined('ABSPATH') ) {
    	exit;
    }
    
    $attrs = is_user_logged_in()
    	? 'href="#" data-toggle="modal" data-target="#report-listing-modal"'
    	: sprintf( 'href="%s"', esc_url( \MyListing\get_login_url() ) );
    ?>
    <li id="<?php echo esc_attr( $action['id'] ) ?>" class="<?php echo esc_attr( $action['class'] ) ?>">
        <a <?php echo $attrs ?>>
        	<?php echo c27()->get_icon_markup( $action['icon'] ) ?>
        	<span><?php echo $action['label'] ?></span>
        </a>
    </li>
Viewing 6 replies - 1 through 6 (of 6 total)
  • Is it safe to delete this part?

    I wouldn’t recommend to allow unregistered users to do actions

    Thread Starter majaxlt

    (@majaxlt)

    Thank you for your input.

    It’s just for reporting broken links on my directory website. Noone wants to register just to report broken link.

    Moderator bcworkz

    (@bcworkz)

    You cannot just delete, but you can remove the ternary operators to take the log in check out of the picture.
    $attrs = 'href="#" data-toggle="modal" data-target="#report-listing-modal"';

    We don’t know what sort of sanitation or validation is applied to submitted form data, nor what is otherwise done with it, so cannot comment on how safe such a change will be.

    Thread Starter majaxlt

    (@majaxlt)

    Thank you! I will play around with it on the staging server.

    It’s just for reporting broken links on my directory website. Noone wants to register just to report broken link.

    May be create a form with Ninja Forms or ACF, and put a link in the sidebar to report a broken link instead?

    Thread Starter majaxlt

    (@majaxlt)

    @a2hostingrj

    Report Listing is a built-in function in this theme and custom solution wouldn’t look good. But thank you for the idea.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.